/* ===== Global Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1f1f35;
    --bg-input: #16213e;
    --text: #e2e8f0;
    --text-muted: #a0aec0;
    --border: #2d3748;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* ===== Login Page ===== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 50%, #0f0f23 100%);
    position: relative;
    overflow: hidden;
}

.particles {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 4px; height: 4px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.3;
    animation: float 15s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translateY(0) translateX(0); opacity: 0.3; }
    25% { transform: translateY(-100px) translateX(50px); opacity: 0.6; }
    50% { transform: translateY(-200px) translateX(-30px); opacity: 0.3; }
    75% { transform: translateY(-100px) translateX(80px); opacity: 0.5; }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: slideUp 0.6s ease;
}

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

.login-icon {
    width: 80px; height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(102,126,234,0.4); }
    50% { box-shadow: 0 0 0 15px rgba(102,126,234,0); }
}

.login-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}

.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-group input {
    width: 100%;
    padding: 14px 48px 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    transition: all 0.3s;
    direction: ltr;
    text-align: center;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2);
}

.toggle-pass {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

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

.login-message {
    margin-top: 16px;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.login-message.show { display: block; }
.login-message.error { background: rgba(245,101,101,0.15); color: var(--danger); }
.login-message.success { background: rgba(72,187,120,0.15); color: var(--success); }

/* ===== Navbar ===== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-navbar {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.nav-brand {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    padding: 6px 14px;
    background: rgba(102,126,234,0.15);
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.admin-badge {
    background: rgba(237,137,54,0.15);
    border-color: var(--warning);
    color: var(--warning);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.nav-btn:hover {
    border-color: var(--primary);
    background: rgba(102,126,234,0.1);
}

.team-nav-btn:hover {
    border-color: var(--warning);
    background: rgba(237,137,54,0.1);
    color: var(--warning);
}

.logout-btn:hover {
    border-color: var(--danger);
    background: rgba(245,101,101,0.1);
    color: var(--danger);
}

/* ===== Admin Page ===== */
.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.folders-icon { background: rgba(102,126,234,0.15); }
.files-icon { background: rgba(72,187,120,0.15); }
.size-icon { background: rgba(237,137,54,0.15); }

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
}

/* Section Card */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.section-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(102,126,234,0.05);
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.section-body {
    padding: 24px;
}

/* Input & Buttons */
.input-field {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.select-field {
    cursor: pointer;
    min-width: 200px;
}

.folder-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.folder-input-row .input-field {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}

.btn-danger {
    background: rgba(245,101,101,0.15);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 16px;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(102,126,234,0.05);
}

.upload-area p {
    color: var(--text-muted);
    margin-top: 8px;
}

.upload-hint {
    font-size: 12px;
    opacity: 0.6;
}

.upload-progress {
    margin-top: 16px;
}

.upload-progress .progress-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(72,187,120,0.1);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--success);
}

/* Folders Grid */
.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.folder-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s;
}

.folder-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.folder-card-header {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(102,126,234,0.05);
}

.folder-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-card-body {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: background 0.2s;
}

.file-item:hover {
    background: rgba(102,126,234,0.1);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.file-name {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ===== User Page ===== */
.user-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.user-content {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-top: 16px;
    font-size: 20px;
}

.empty-state p {
    margin-top: 8px;
    font-size: 14px;
}

/* User Folder Card */
.user-folder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.user-folder-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.1));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-folder-header h3 {
    font-size: 18px;
}

.user-folder-body {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.user-file-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.user-file-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.file-preview {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    overflow: hidden;
}

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

.file-preview .big-icon {
    font-size: 48px;
}

.file-label {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-top: 1px solid var(--border);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(245,101,101,0.2);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow: auto;
    flex: 1;
}

.modal-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.modal-body pre {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid var(--border);
}

.modal-body iframe {
    width: 100%;
    height: 500px;
    border: none;
    border-radius: var(--radius-sm);
}

.modal-body .pdf-viewer {
    width: 100%;
    height: 600px;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    margin-top: 16px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    box-shadow: var(--shadow);
    z-index: 2000;
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .nav-left {
        flex-wrap: wrap;
        justify-content: center;
    }

    .folder-input-row {
        flex-direction: column;
    }

    .admin-main, .user-main {
        padding: 16px;
    }

    .login-card {
        padding: 32px 24px;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

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

    .user-folder-body {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

.hidden { display: none !important; }

/* ===== Firebase Status ===== */
.firebase-status-card {
    margin-bottom: 16px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px rgba(72,187,120,0.5);
    animation: dotPulse 2s infinite;
}

.status-dot.disconnected {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(245,101,101,0.5);
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Tabs ===== */
.tabs-row {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(102,126,234,0.1);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* ===== Team Edit Styles ===== */
.team-edit-card {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.team-edit-photo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    background: linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
                linear-gradient(135deg, var(--primary), var(--secondary)) border-box;
    position: relative;
    flex-shrink: 0;
}

.team-edit-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.photo-placeholder-edit {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15));
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 10px;
    line-height: 1.4;
}

.team-edit-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-sm {
    padding: 8px 12px !important;
    font-size: 13px !important;
}

/* Team Group Admin */
.team-group-admin {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.team-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(102,126,234,0.05);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.team-group-name-edit {
    display: flex;
    align-items: center;
    gap: 10px;
}

.team-group-name-edit .input-sm {
    min-width: 200px;
}

.team-group-actions {
    display: flex;
    gap: 8px;
}

.team-group-members {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-member-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.group-member-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

.group-member-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-placeholder-small {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15));
    font-size: 20px;
}

.photo-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 18px;
}

.group-member-photo:hover .photo-overlay {
    opacity: 1;
}

.group-member-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.group-member-info .input-sm {
    width: 100%;
}

/* ===== Responsive Team Edit ===== */
@media (max-width: 768px) {
    .team-edit-card {
        flex-direction: column;
        align-items: center;
    }

    .team-edit-photo {
        width: 130px;
        height: 130px;
    }

    .team-edit-fields {
        width: 100%;
    }

    .team-group-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .group-member-item {
        flex-wrap: wrap;
    }

    .group-member-info {
        min-width: 150px;
    }

    .tabs-row {
        flex-direction: column;
    }
}
