:root {
    /* Light Mode Palette */
    --purple-primary: #7c3aed;
    --purple-hover: #6d28d9;
    --black-text: #111827;
    --silver-bg: #f3f4f6;
    --silver-panel: #ffffff;
    --silver-border: #e5e7eb;
    --white: #ffffff;

    --bg-color: var(--silver-bg);
    --panel-color: var(--silver-panel);
    --text-primary: var(--black-text);
    --text-secondary: #4b5563;
    --border-color: var(--silver-border);
    --transition: all 0.3s ease;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.dark-mode {
    /* Dark Mode Palette */
    --bg-color: #0d0d12;
    --panel-color: #1a1a24;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #2d2d3b;
    --purple-primary: #8b5cf6;
    --purple-hover: #a78bfa;
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background-color: var(--panel-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: #888;
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: auto;
}
.logout-btn:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.logo-icon {
    width: 42px;
    height: 42px;
    color: var(--purple-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.logo:hover .logo-icon {
    transform: scale(1.1) rotate(-5deg);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Theme Toggle */
#themeToggleBtn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#themeToggleBtn:hover {
    color: var(--purple-primary);
    background-color: rgba(124, 58, 237, 0.1);
}

#themeToggleBtn svg {
    width: 24px;
    height: 24px;
}

.moon-icon {
    display: none;
}

.dark-mode .sun-icon {
    display: none;
}

.dark-mode .moon-icon {
    display: block;
}

/* Main Layout */
.dashboard {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

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

/* Panels */
.panel {
    background-color: var(--panel-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: -1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.row-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.row-group input {
    flex-grow: 1;
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

input[type="text"],
input[type="url"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--purple-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

small {
    display: block;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

/* File Drop Area */
.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    transition: var(--transition);
    background-color: rgba(0, 0, 0, 0.02);
    cursor: pointer;
}

.dark-mode .file-drop-area {
    background-color: rgba(255, 255, 255, 0.02);
}

.file-drop-area:hover,
.file-drop-area.drag-over {
    border-color: var(--purple-primary);
    background-color: rgba(124, 58, 237, 0.05);
}

.file-msg {
    color: var(--text-secondary);
    font-weight: 500;
}

.file-drop-area input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    cursor: pointer;
    opacity: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--purple-primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--purple-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
}

.btn-outline {
    background-color: transparent;
    color: var(--purple-primary);
    border: 1px solid var(--purple-primary);
}

.btn-outline:hover {
    background-color: rgba(124, 58, 237, 0.1);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Client List */
.clients-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.client-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: var(--transition);
}

.client-item:hover {
    border-color: var(--purple-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.client-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.client-info a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
}

.client-info a:hover {
    color: var(--purple-primary);
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    background-color: var(--bg-color);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
}

/* Client Actions Layout */
.client-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Inactive Client State */
.client-item.inactive {
    opacity: 0.5;
    border-style: dashed;
}

.client-item.inactive:hover {
    opacity: 0.75;
}

/* Status Badge */
.status-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.inactive-badge {
    background-color: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* Button Variants */
.btn-danger {
    background-color: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.btn-danger:hover {
    background-color: #e74c3c;
    color: white;
}

.btn-warn {
    background-color: transparent;
    color: #f39c12;
    border: 1px solid #f39c12;
}

.btn-warn:hover {
    background-color: #f39c12;
    color: white;
}

.btn-success {
    background-color: transparent;
    color: #2ecc71;
    border: 1px solid #2ecc71;
}

.btn-success:hover {
    background-color: #2ecc71;
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--panel-color);
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--white);
    /* Always white for contrast */
    border-radius: 12px;
}

.qr-container img {
    width: 200px;
    height: 200px;
}

.url-display {
    font-size: 0.8rem;
    color: #4b5563;
    /* Fixed dark for white bg */
    word-break: break-all;
    text-align: center;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Utilities */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* File Manager */
.file-manager-content {
    max-width: 550px;
}

.file-list-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-list-container::-webkit-scrollbar {
    width: 6px;
}
.file-list-container::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}
.file-list-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition);
}

.file-item:hover {
    border-color: var(--purple-primary);
}

.file-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
    flex-grow: 1;
    margin-right: 1rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.file-item-name:hover {
    background-color: rgba(124, 58, 237, 0.1);
    color: var(--purple-primary);
}

.rename-input {
    flex-grow: 1;
    margin-right: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--purple-primary);
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.file-actions-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mini-upload-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.btn-premium {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    box-shadow: 0 4px 14px 0 rgba(124, 58, 237, 0.39);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-premium::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
    background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%);
}

.btn-premium:hover::after {
    opacity: 1;
}

.btn-premium:active {
    transform: translateY(0);
}

.btn-text-only {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.btn-text-only:hover {
    color: var(--purple-primary);
    background-color: rgba(124, 58, 237, 0.1);
}

.mini-upload-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.row-group-upload {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.custom-file-selector {
    flex-grow: 1;
    position: relative;
    cursor: pointer;
}

.hidden-input {
    display: none;
}

.custom-file-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background-color: var(--bg-color);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
}

.custom-file-label:hover {
    border-color: var(--purple-primary);
    background-color: rgba(124, 58, 237, 0.05);
    color: var(--text-primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.upload-icon {
    width: 20px;
    height: 20px;
    color: var(--purple-primary);
    flex-shrink: 0;
}

.mini-upload-section .btn-premium {
    height: 42px;
    white-space: nowrap;
}

.btn.loading span {
    display: none;
}

.btn.loading .spinner {
    display: block;
}

to {
    transform: rotate(360deg);
}
}