/**
 * Lumio SaaS — Main Stylesheet
 * Dark theme, high-tech aesthetic with electric blue accents.
 * Mobile-responsive, modular component system.
 */

/* ========================================
   CSS VARIABLES / DESIGN TOKENS
   ======================================== */
:root {
    /* Colors */
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f2a;
    --bg-card: #12122e;
    --bg-hover: #1a1a3e;
    --bg-input: #0d0d24;
    --bg-sidebar: #080820;

    --text-primary: #e8e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-border: rgba(59, 130, 246, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --border: #1e293b;
    --border-light: #2d3748;

    /* Spacing */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(59,130,246,0.1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: 180ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

/* ========================================
   LAYOUT — AUTH PAGES (Login/Register)
   ======================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.04) 0%, transparent 50%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo img {
    height: 48px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-card h2 {
    margin-bottom: 0.5rem;
}

.auth-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========================================
   LAYOUT — APP (Sidebar + Content)
   ======================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header img {
    height: 32px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
}

.sidebar-logo {
    height: 12px;
    width: auto;
    max-width: 40px;
    object-fit: contain;
}

.ithink-logo {
    height: 20px;
    width: auto;
    max-width: 80px;
    object-fit: contain;
}

.mobile-logo {
    height: 28px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}
.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}
.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}
.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
    overflow: hidden;
}
.sidebar-footer img {
    height: 20px !important;
    width: auto !important;
    max-width: 80px !important;
    opacity: 0.5;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
}
.sidebar-brand img {
    height: 20px !important;
    width: auto !important;
    max-width: 80px !important;
    object-fit: contain;
    flex-shrink: 0;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    z-index: 150;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    gap: 5px;
    padding: 10px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger:active {
    background: var(--accent);
    border-color: var(--accent);
}

.hamburger:active span {
    background: #fff;
}

.mobile-credits {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-credits svg {
    color: var(--accent);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Mobile sidebar toggle (legacy) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        z-index: 200;
    }
    .sidebar-toggle {
        display: block;
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 68px;
    }
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.5rem;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.card-header h3 {
    font-size: 1rem;
}
.card-body {
    padding: 1.25rem;
}
.card-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-light);
}
.btn-outline:hover { background: var(--bg-hover); border-color: var(--accent-border); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover { background: #059669; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-xs { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px;
    transition: color var(--transition);
}
.btn-icon:hover { color: var(--text-primary); }

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="color"] {
    width: 50px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary) !important;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.input-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    padding-left: 38px;
}

/* ========================================
   TABLES
   ======================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.data-table tr:hover td {
    background: var(--bg-hover);
}
.data-table code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.devices-table-container {
    overflow-x: auto;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); border-color: rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.badge-info { background: rgba(6,182,212,0.15); color: var(--info); border-color: rgba(6,182,212,0.3); }

/* ========================================
   STATUS DOTS
   ======================================== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 6px;
}
.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16,185,129,0.5);
    animation: pulse-green 2s infinite;
}
.status-dot.offline {
    background: var(--text-muted);
}
@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   MODALS
   ======================================== */
 
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 600px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-body {
    padding: 1.5rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}
.modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    z-index: 9999;
    animation: toast-in 300ms cubic-bezier(0.23, 1, 0.32, 1), toast-out 300ms 2700ms forwards;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ========================================
   SCREENS GRID
   ======================================== */
.screens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.screen-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
}
.screen-card:hover {
    border-color: var(--accent-border);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.screen-preview {
    height: 160px;
    padding: 8px;
    position: relative;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}
.screen-res {
    background: rgba(0,0,0,0.6);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 10;
}

.screen-info {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}
.screen-info h4 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
.screen-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========================================
   EDITOR
   ======================================== */
.editor-page {
    margin: -2rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh);
    max-width: calc(100vw - var(--sidebar-width));
    overflow: hidden;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}
.editor-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.editor-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-canvas-container {
    flex: 1;
    min-width: 0; /* allow flex shrink */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #050510;
    overflow: hidden;
}

.editor-canvas {
    width: 100%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    touch-action: none;
}

.canvas-element {
    position: absolute;
    cursor: move;
    border: 2px solid transparent;
    transition: border-color 100ms;
    overflow: hidden;
    box-sizing: border-box;
    touch-action: none; /* prevent scroll during element manipulation */
    -webkit-user-select: none;
    user-select: none;
}
.canvas-element:hover { border-color: rgba(59,130,246,0.4); }
.canvas-element.selected { border-color:var(--accent);}
.canvas-element img {
    position: absolute;
    inset: 0;

    min-width: 100%;
    min-height: 100%;

    width: 100%;
    height: 100%;

    object-fit: fill;

    display: block;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--accent);
    cursor: se-resize;
    border-radius: 2px 0 0 0;
    opacity: 0;
    transition: opacity var(--transition);
}
.canvas-element.selected .resize-handle,
.canvas-element:hover .resize-handle {
    opacity: 1;
}

/* Editor Panel */
.editor-panel {
    width: 280px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.panel-tab {
    flex: 1;
    padding: 0.6rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
}
.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel-content {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

/* Layers */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background var(--transition);
}
.layer-item:hover { background: var(--bg-hover); }
.layer-item.selected { background: var(--accent-glow); border: 1px solid var(--accent-border); }
.layer-type { font-size: 1rem; }
.layer-name { color: var(--text-secondary); }

/* ========================================
   GALLERY
   ======================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.gallery-item:hover {
    border-color: var(--accent-border);
    transform: scale(1.02);
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    opacity: 0;
    transition: opacity var(--transition);
}
.gallery-item:hover .gallery-item-overlay { opacity: 1; }
.gallery-item-name { font-size: 0.75rem; color: #fff; display: block; }
.gallery-item-size { font-size: 0.7rem; color: var(--text-muted); }

.gallery-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    align-items: center;
}
.gallery-toolbar select {
    width: auto;
    min-width: 150px;
}

.gallery-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}
.gallery-thumb:hover { border-color: var(--accent); }

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.upload-zone svg { margin-bottom: 0.75rem; color: var(--text-muted); }
.upload-zone p { font-size: 0.9rem; margin-bottom: 0.25rem; }
.upload-hint { font-size: 0.78rem; color: var(--text-muted); }

/* Preview modal image */
.preview-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: #000;
}
.preview-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.url-code {
    display: block;
    word-break: break-all;
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ========================================
   BILLING / PLANS
   ======================================== */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    transition: all var(--transition);
}
.plan-card:hover {
    border-color: var(--accent-border);
    box-shadow: var(--shadow-glow);
}
.plan-card.featured {
    border-color: var(--accent);
    box-shadow: 0 0 30px rgba(59,130,246,0.15);
}
.plan-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.plan-card-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.plan-card-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.plan-price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-heading);
}
.plan-price span {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
}

.plan-features {
    list-style: none;
    padding: 1.25rem 1.5rem;
}
.plan-features li {
    padding: 0.4rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    position: relative;
    padding-left: 1.5rem;
}
.plan-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

.plan-card .btn {
    margin: 0 1.5rem 1.5rem;
    width: calc(100% - 3rem);
}

.plan-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}
.plan-starter { background: rgba(100,116,139,0.2); color: #94a3b8; }
.plan-professional { background: rgba(59,130,246,0.2); color: #3b82f6; }
.plan-enterprise { background: rgba(139,92,246,0.2); color: #8b5cf6; }

/* Credits */
.credits-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}
.credits-balance {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.credits-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}
.credits-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.credits-usage p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
 

.ai-credits-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ========================================
   DASHBOARD
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.stat-icon.orange { background: rgba(245,158,11,0.15); color: var(--warning); }

.stat-info h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
}
.stat-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.dashboard-grid {
    display: grid;
    grid-template-columns:
        minmax(320px,1.2fr)
        minmax(320px,1.2fr)
        minmax(260px,1fr)
        minmax(260px,1fr);

    gap: 1.5rem;
}
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--transition);
}
.quick-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-border);
    color: var(--accent);
}
.quick-action-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
 
/* ========================================
   DEVICES
   ======================================== */
.info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.75rem 1rem;
    background: rgba(59,130,246,0.08);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.info-banner svg { flex-shrink: 0; color: var(--accent); }

/* ========================================
   SETTINGS
   ======================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
}

.copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.copy-field code {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.logo-upload-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.current-logo-preview {
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    padding: 4px 8px;
}

.feeds-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.feed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.feed-info { flex: 1; }
.feed-info strong { display: block; font-size: 0.85rem; }
.feed-info code { font-size: 0.75rem; color: var(--text-muted); }

/* ========================================
   ACCOUNT
   ======================================== */
.plan-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.plan-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.plan-summary-row span { color: var(--text-secondary); }
.plan-summary-row strong { color: var(--text-heading); }

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.session-info strong { display: block; font-size: 0.85rem; }
.session-info span { font-size: 0.75rem; color: var(--text-muted); }

.danger-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
    font-size: 0.875rem;
}

.empty-state-large {
    text-align: center;
    padding: 3rem 2rem;
    grid-column: 1 / -1;
}
.empty-state-large svg {
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.empty-state-large h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
.empty-state-large p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.empty-state-sm {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========================================
   UTILITIES
   ======================================== */
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

.current-plan-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
    .editor-panel { width: 240px; }
    /* .editor-canvas size handled by fitCanvas() */
}
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .plans-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .credits-info { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .screens-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
/* ---------- Créditos ---------- */
.credits-badge {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 12px 16px;
    margin-bottom: 20px;

    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.credits-icon {
    width: 18px;
    height: 18px;
    opacity: .8;
    flex-shrink: 0;
}

.credits-label {
    flex: 1;
    color: #94a3b8;
    font-size: 14px;
}

#credits-count {
    font-size: 18px;
    font-weight: 700;
    color: white;
}
/* ---------- Utilizador ---------- */

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-top: 15px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.user-plan {
    display: block;
    font-size: 13px;
    color:#7c93c7;
    text-transform: capitalize;
}

.user-info .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 4px;
    color: #94a3b8;
    background: transparent;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    transition: .2s;
}


.user-info .btn-icon:hover {
    color: white;
}


.user-info .btn-icon svg {
    width: 18px;
    height: 18px;
}


.sidebar-brand{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    margin-top:15px;
    opacity:.6;
    font-size:12px;
}


.ithink-logo{
    height:14px;
}

.credits-badge {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
}
.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.device-item:last-child {
    border-bottom: none;
}

.device-name {
    font-size: 14px;
    font-weight: 600;
}

.device-screen {
    font-size: 12px;
    color: var(--text-muted);
}
.layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
}

.layer-actions {
    display: flex;
    gap: 4px;
}

.layer-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255,255,255,.08);
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

.layer-btn:hover {
    background: rgba(255,255,255,.15);
}

.ai-history-modal{
    max-width:900px;
}

.history-card{
    display:flex;
    align-items:center;
    gap:16px;

    padding:12px;
    margin-bottom:12px;

    background:rgba(255,255,255,.03);
    border:1px solid var(--border);
    border-radius:12px;
}

.history-thumb{
    width:120px;
    height:80px;
    object-fit:cover;
    border-radius:8px;
}

.history-info{
    flex:1;
}

.history-prompt{
    font-weight:600;
    color:white;
    margin-bottom:8px;
}

.history-meta{
    color:#94a3b8;
    font-size:13px;
}

 

.modal-overlay{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.modal-overlay.show {
    display: flex;
}


/* ========================================
   AI SMART MODE — TEMPLATE SELECTOR & FORM
   ======================================== */

.modal-xl {
    max-width: 800px;
    width: 95%;
}

.ai-mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.ai-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ai-tab.active {
    background: var(--accent);
    color: #fff;
}

.ai-mode-panel {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.template-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 12px var(--accent-glow);
}

.template-icon {
    font-size: 1.8rem;
}

.template-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
}

.smart-form-header {
    margin: 1rem 0 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-hover);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.smart-form-header h4 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    color: var(--text-heading);
}

.smart-form-header p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.form-input-color {
    width: 60px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    cursor: pointer;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.required {
    color: var(--danger);
}

/* ========================================
   DEVICES PAGE
   ======================================== */

.devices-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--accent-glow);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.devices-info-banner p {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.devices-info-banner strong {
    color: var(--text-heading);
    font-size: 0.9rem;
}

.devices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.slots-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slots-badge {
    padding: 0.4rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.slots-available {
    font-size: 0.82rem;
    color: var(--success);
}

.devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.device-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
    overflow: hidden;
}

.device-card-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.device-card-urls {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.device-url-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.device-card:hover {
    border-color: var(--accent-border);
}

.device-card.inactive {
    opacity: 0.5;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 80px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.device-status.online .status-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.device-status.offline .status-dot {
    background: var(--text-muted);
}

.status-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.device-info {
    flex: 1;
}

.device-name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-heading);
}

.device-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.3rem;
}

.device-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.device-actions {
    display: flex;
    gap: 0.5rem;
}

.device-url-item .url-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    min-width: 42px;
}
.device-url-item .url-code {
    flex: 1;
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 4px;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.device-url-item .btn-copy {
    flex-shrink: 0;
}

.screen-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

/* ========================================
   DASHBOARD IMPROVEMENTS
   ======================================== */

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent-glow);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
}

.stat-icon.devices svg { stroke: var(--success); }
.stat-icon.devices { background: rgba(16, 185, 129, 0.1); }
.stat-icon.media svg { stroke: var(--warning); }
.stat-icon.media { background: rgba(245, 158, 11, 0.1); }
.stat-icon.credits svg { stroke: #a855f7; }
.stat-icon.credits { background: rgba(168, 85, 247, 0.1); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.stat-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dashboard-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.section-title {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.action-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.action-card svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
}

.action-card span {
    font-size: 0.82rem;
    font-weight: 500;
}

.info-card {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-of-type {
    border-bottom: none;
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.viewer-url-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viewer-url-row code {
    font-size: 0.78rem;
    background: var(--bg-primary);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    color: var(--accent);
    word-break: break-all;
}

.info-help {
    margin: 0.75rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
}

.activity-icon.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.activity-icon.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.activity-info {
    display: flex;
    flex-direction: column;
}

.activity-desc {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state-box h3 {
    margin: 0;
    color: var(--text-heading);
}

.empty-state-box p {
    margin: 0;
    font-size: 0.85rem;
}

/* ========================================
   RESPONSIVE FIXES
   ======================================== */

@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .device-card-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .device-card-urls {
        flex-direction: column;
    }

    .device-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ========================================
   MOBILE OPTIMISATION
   ======================================== */

/* --- Editor: Full-screen immersive on mobile --- */
@media (max-width: 768px) {

    /* Editor takes full viewport */
    .editor-page {
        margin: 0 !important;
        height: 100vh;
        height: 100dvh; /* dynamic viewport for mobile browsers */
        border-radius: 0;
    }

    /* Header: compact, scrollable toolbar */
    .editor-header {
        padding: 0.5rem 0.75rem;
        gap: 6px;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .editor-header-left {
        gap: 8px;
        min-width: 0;
    }

    .editor-header-left h2 {
        font-size: 0.9rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .editor-header-left .badge {
        display: none; /* hide resolution badge on mobile */
    }

    .editor-header-right {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .editor-header-right::-webkit-scrollbar {
        display: none;
    }

    .editor-header-right .btn {
        flex-shrink: 0;
        font-size: 0.72rem;
        padding: 0.35rem 0.5rem;
        gap: 3px;
        white-space: nowrap;
    }

    .editor-header-right .btn svg {
        width: 14px;
        height: 14px;
    }

    /* Body: stacked layout */
    .editor-body {
        flex-direction: column;
        overflow: hidden;
    }

    /* Canvas: takes available space */
    .editor-canvas-container {
        flex: 1;
        padding: 0.5rem;
        min-height: 0;
    }

    .editor-canvas {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        height: auto;
        aspect-ratio: 16 / 9;
        margin: 0 auto;
    }

    /* Panel: bottom drawer */
    .editor-panel {
        width: 100%;
        max-height: 45vh;
        max-height: 45dvh;
        border-left: none;
        border-top: 1px solid var(--border);
        overflow-y: auto;
    }

    .panel-tabs {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-card);
    }

    .panel-tab {
        padding: 0.5rem 0.4rem;
        font-size: 0.72rem;
    }

    .panel-content {
        padding: 0.75rem;
    }

    /* Layers list: horizontal scroll on mobile */
    .layers-list {
        max-height: 150px;
        overflow-y: auto;
    }

    /* Hide main-content padding for editor */
    .main-content:has(.editor-page) {
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* --- Modals: full-screen on mobile --- */
@media (max-width: 768px) {

    .modal-overlay {
        align-items: flex-end; /* slide up from bottom */
    }

    .modal,
    .modal.modal-lg,
    .modal.modal-xl {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }

    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 10;
    }

    .modal-header h3,
    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-actions {
        padding: 0.75rem 1rem;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        z-index: 10;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-actions .btn {
        flex: 1;
        min-width: 0;
        font-size: 0.82rem;
        padding: 0.6rem 0.75rem;
    }

    /* AI modal specifics */
    .ai-mode-tabs {
        margin-bottom: 1rem;
    }

    .ai-tab {
        padding: 0.6rem 0.5rem;
        font-size: 0.8rem;
    }

    .template-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem;
    }

    .template-card {
        padding: 0.6rem 0.3rem;
    }

    .template-icon {
        font-size: 1.4rem;
    }

    .template-name {
        font-size: 0.68rem;
    }

    .smart-form-header {
        margin: 0.75rem 0 0.4rem;
        padding: 0.5rem 0.75rem;
    }

    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    /* History cards */
    .history-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 0.75rem;
    }

    .history-thumb {
        width: 100%;
        height: 120px;
        border-radius: 6px;
    }

    /* Gallery grid in modals */
    .gallery-grid-sm {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
}

/* --- Extra small screens (< 480px) --- */
@media (max-width: 480px) {

    .editor-header {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-header-left {
        justify-content: space-between;
    }

    .editor-header-right {
        justify-content: flex-start;
    }

    .editor-canvas {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        height: auto;
        aspect-ratio: 16 / 9;
        margin: 0 auto;
    }

    .editor-panel {
        max-height: 50vh;
        max-height: 50dvh;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Make form inputs bigger for touch */
    .form-input,
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* prevents iOS zoom */
        padding: 0.6rem 0.75rem;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

/* --- Touch improvements --- */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .canvas-element {
        min-width: 30px;
        min-height: 30px;
    }

    .resize-handle {
        width: 24px;
        height: 24px;
        opacity: 0.7;
    }

    .canvas-element.selected .resize-handle {
        opacity: 1;
    }

    /* Bigger buttons for touch */
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }

    .panel-tab {
        min-height: 40px;
    }

    .layer-item {
        padding: 0.7rem;
        min-height: 44px;
    }

    /* Template cards bigger tap area */
    .template-card {
        min-height: 70px;
    }
}

/* --- Landscape phone (editor in landscape) --- */
@media (max-width: 900px) and (orientation: landscape) {

    .editor-body {
        flex-direction: row;
    }

    .editor-canvas-container {
        flex: 1;
        padding: 0.5rem;
    }

    .editor-canvas {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 60px);
        aspect-ratio: 16 / 9;
    }

    .editor-panel {
        width: 220px;
        max-height: none;
        border-top: none;
        border-left: 1px solid var(--border);
    }
}

/* --- Mobile header: hide when in editor --- */
@media (max-width: 768px) {
    .app-layout:has(.editor-page) .mobile-header {
        display: none;
    }

    .app-layout:has(.editor-page) .sidebar-overlay {
        display: none;
    }

    .app-layout:has(.editor-page) > .main-content {
        padding: 0 !important;
        padding-top: 0 !important;
    }
}
