:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-hover: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --font-family: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    /* Reduced from 24px */
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 30px;
    line-height: 1.2;
}

#welcome-msg {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.logo i {
    color: var(--primary);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 24px 0;
}

.nav-section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    margin: 24px 0 12px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.nav-item:hover,
.nav-item.active {
    background: var(--glass);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item i {
    width: 20px;
}

.add-category-btn {
    border: 1px dashed var(--border);
    color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.user-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
}

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

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

.user-info .role {
    font-size: 11px;
    color: var(--text-muted);
}

.user-profile .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.logout-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

.logout-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.top-bar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    width: 400px;
    gap: 12px;
}

.search-bar i {
    color: var(--text-muted);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
    width: 100%;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--glass);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--glass-hover);
}

.icon-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

.primary-btn {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.secondary-btn {
    padding: 10px 24px;
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.secondary-btn:hover {
    background: var(--glass);
}


/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
    overflow-y: auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.view-controls {
    display: flex;
    gap: 8px;
}

/* Document Grid */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.document-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.document-card:hover {
    transform: translateY(-4px);
    background: var(--glass-hover);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.2);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.card-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-info p {
    font-size: 13px;
    color: var(--text-muted);
}

.card-meta {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tag-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.doc-menu-btn {
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.doc-menu-btn:hover {
    color: var(--text-main);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 500px;
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-zone i {
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 14px;
}

.drop-zone span {
    color: var(--primary);
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.hidden {
    display: none !important;
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 12px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-option.selected {
    border-color: white;
    transform: scale(1.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.empty-state img {
    width: 200px;
    margin-bottom: 24px;
    opacity: 0.8;
}

.empty-state h3 {
    color: var(--text-main);
    margin-bottom: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Nav Group for Edit */
.nav-group {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.nav-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-group.active .nav-item-content {
    background: var(--primary);
    color: white;
}

.nav-group:hover .nav-item-content {
    background: var(--glass);
    color: var(--text-main);
}

.nav-group.active:hover .nav-item-content {
    background: var(--primary);
}

.nav-item-action {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.nav-group:hover .nav-item-action {
    opacity: 1;
}

.nav-item-action:hover {
    background: var(--glass-hover);
    color: white;
}

/* Upload Mode Switch */
.upload-mode-switch {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--glass-hover);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-item-action.delete:hover {
    color: #ef4444;
}

/* Mobile Responsiveness */
.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--glass);
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
        background: rgba(13, 17, 23, 0.98);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .main-content {
        padding: 16px;
    }

    .top-bar {
        padding: 12px;
        gap: 12px;
    }

    .search-bar {
        width: 100%;
    }

    .document-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .logo {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .actions {
        display: none;
        /* Hide non-essential headers on small phones if needed */
    }

    #zip-download-btn {
        display: none;
        /* Usually better to hide complex actions on tiny screens */
    }

    .modal {
        width: 95%;
        margin: 10px;
        padding: 20px;
    }

    .upload-mode-switch {
        flex-direction: column;
    }

    .document-grid {
        grid-template-columns: 1fr;
    }

    .doc-card {
        padding: 12px;
    }
}

/* File Preview Styles */
.file-preview {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
}

.preview-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: var(--glass);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb i {
    font-size: 24px;
    color: var(--primary);
}

.file-meta-info {
    flex: 1;
}

.file-meta-info .file-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-all;
}

.file-meta-info .file-details {
    font-size: 12px;
    color: var(--text-muted);
}

/* Preview Modal Specifics */
.preview-modal-size {
    max-width: 600px;
    width: 90%;
}

.preview-content-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 20px 0;
}

.preview-large-icon {
    width: 120px;
    height: 120px;
    background: var(--glass-hover);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.preview-large-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 20px;
}

.preview-info-card {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.info-row .label {
    color: var(--text-muted);
    font-size: 14px;
}

.info-row .value {
    color: white;
    font-weight: 500;
    font-size: 14px;
}