@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-page: #0f111a;
    --bg-sidebar: #161b28;
    --bg-card: #1e2332;
    --bg-input: #272e41;
    --bg-hover: #2a3042;

    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    /* Pink 500 */

    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --border: #2d3748;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius: 12px;
    --radius-sm: 8px;

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    font-size: 14px;
    overflow-y: auto;
    /* Allow scroll by default for landing/auth/legal */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Layout for Dashboard */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    /* App feel for dashboard */
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s;
}

.brand {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}

.brand span {
    color: var(--text-main);
    margin-left: 6px;
}

.nav-menu {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: 0.2s;
}

.nav-item svg {
    margin-right: 12px;
    width: 20px;
    height: 20px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.nav-label {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin: 24px 16px 8px;
    letter-spacing: 0.05em;
}

.user-profile {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info div:first-child {
    font-weight: 600;
}

.user-info div:last-child {
    color: var(--text-muted);
    font-size: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: 70px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-page);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

.content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* UI Elements */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 13px;
    transition: 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #374151;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.input,
.textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: 0.2s;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Drag and Drop Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    transition: 0.2s;
    background: rgba(30, 35, 50, 0.5);
    cursor: pointer;
    margin-bottom: 24px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Card Grid */
.grid-projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.project-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: 0.2s;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.file-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: 0.2s;
    position: relative;
    group: hover;
}

.file-card:hover {
    border-color: var(--text-muted);
}

.file-preview {
    height: 140px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s;
}

.file-card:hover .file-preview img {
    transform: scale(1.05);
}

.file-info {
    padding: 12px;
}

.file-name {
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    width: 400px;
    padding: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transform: scale(0.95);
    transition: 0.2s;
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(100%);
    transition: 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    font-weight: 500;
}

.toast.active {
    transform: translateX(0);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 160px;
    z-index: 1500;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    padding: 4px;
}

.context-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-item:hover {
    background: var(--primary);
    color: white;
}

/* Auth */
.auth-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-page) 0%, #1a1e2e 100%);
}

.auth-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    /* Layout */
    .app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Sidebar */
    .sidebar {
        width: 100%;
        height: 64px;
        /* Fixed header height */
        min-height: 64px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        overflow: visible;
        /* Needed for absolute positioning of menu */
        background: var(--bg-sidebar);
    }

    .brand {
        height: 64px;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        background: var(--bg-sidebar);
        /* Cover menu when closed */
        z-index: 1001;
        /* Stay on top */
    }

    /* Mobile Menu Toggle */
    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: white;
        cursor: pointer;
        z-index: 1002;
    }

    /* Navigation Menu (Hidden by default) */
    .nav-menu {
        display: none;
        flex-direction: column;
        background: var(--bg-sidebar);
        position: absolute;
        top: 64px;
        left: 0;
        width: 100%;
        height: calc(100vh - 64px);
        padding: 20px;
        border-top: 1px solid var(--border);
    }

    .sidebar.mobile-open .nav-menu {
        display: block;
    }

    /* User Profile in Menu */
    .user-profile {
        display: none;
        background: var(--bg-sidebar);
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 20px;
        border-top: 1px solid var(--border);
    }

    .sidebar.mobile-open .user-profile {
        display: flex;
    }

    /* Main Content */
    .main-content {
        flex: 1;
        width: 100%;
        height: calc(100vh - 64px);
        overflow: hidden;
    }

    .top-bar {
        padding: 0 16px;
        height: 60px;
    }

    .page-title {
        font-size: 16px;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .content-area {
        padding: 16px;
        height: calc(100% - 60px);
        overflow-y: auto;
    }

    /* Grid Adjustments */
    .grid-projects {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }

    .file-preview {
        height: 100px;
    }

    /* Upload Zone */
    .upload-zone {
        padding: 20px;
    }

    /* Modals */
    .modal {
        width: 90%;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Action buttons in View Projects */
    div[style*="display: flex; justify-content: space-between"] {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    /* Move the "New Project" button etc to full width or sensible */
    .btn {
        width: 100%;
    }

    div[style*="justify-content: flex-end"] .btn {
        width: auto;
        /* keep modal buttons normal */
    }

    /* Landing navbar specific */
    nav[style*="position: fixed"] {
        padding: 12px 16px !important;
    }

    nav .btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        width: auto !important;
    }
}

/* Default state for toggle */
.mobile-toggle {
    display: none;
}

/* Image Preview Modal */
.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.image-modal-overlay.active {
    display: flex;
}

.image-modal-content {
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.image-modal-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.image-modal-info {
    margin-top: 16px;
    color: white;
    text-align: center;
}

.image-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.image-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.close-image-modal {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 30px;
    padding: 10px;
}

/* Ensure images in dashboard don't link directly but use onclick */
.file-preview {
    cursor: pointer;
}