/* 
   Renssi Image Bank - World Class Dark Theme 
   v2.0 - Premium Dark UI
*/

:root {
    /* Brand Colors */
    --primary-color: #F37021;
    --primary-hover: #ff8c42;
    --primary-dark: #d95e16;

    /* UI Neutrals - Dark Mode */
    --bg-body: #0a0a0a;
    --bg-surface: #141414;
    --bg-card: #1e1e1e;
    --bg-input: #2a2a2a;

    /* Text Colors */
    --text-main: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Borders & Dividers */
    --border-light: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    /* Functional */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Effects */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 15px rgba(243, 112, 33, 0.3);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --font-heading: 'Montserrat', system-ui, sans-serif;
    --font-body: 'Open Sans', system-ui, sans-serif;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

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

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

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
    font-weight: 700;
    margin-bottom: 0.5em;
    letter-spacing: -0.02em;
}

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

a:hover {
    color: var(--primary-hover);
}

/* Utility Classes */
.text-muted {
    color: var(--text-muted) !important;
}

.text-center {
    text-align: center;
}

/* 
   ----------------
   Components 
   ----------------
*/

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
    display: flex;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 6px rgba(243, 112, 33, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(243, 112, 33, 0.3);
}

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

.btn-secondary {
    background: transparent;
    border: 2px solid var(--border-light);
    color: var(--text-main);
}

.btn-secondary:hover {
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.8px;
}

.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
select,
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 2px solid var(--border-light);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(243, 112, 33, 0.1);
    background: var(--bg-surface);
}

/* 
   ----------------
   Login Page 
   ----------------
*/
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1b1b1b, #000);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.brand-logo {
    text-align: center;
    margin-bottom: 40px;
}

/* Helper for logo color fix on dark bg */
.navbar-logo {
    filter: brightness(0) invert(1);
}

.login-box {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 48px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h2 {
    font-size: 1.8rem;
    color: var(--text-main);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

.login-footer {
    display: none;
    /* Hide footer for cleaner look */
}

/* 
   ----------------
   Main UI Layout 
   ----------------
*/

/* Navbar */
.navbar {
    height: 80px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 20px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(243, 112, 33, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.nav-link {
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    margin-left: 20px;
}

.nav-link:hover {
    color: var(--text-main);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link.action-btn {
    border: 1px solid var(--border-light);
    padding: 8px 20px;
    border-radius: var(--radius-full);
}

.nav-link.action-btn:hover {
    background: var(--text-main);
    color: var(--bg-body);
}

/* Hero Section (if used) */
.hero-section {
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.8) 0%, var(--bg-body) 100%), url('../images/hero-bg.jpg');
    background-size: cover;
    /* Fallback if image missing */
    padding: 60px 40px 20px 40px;
    text-align: center;
}

.hero-content h2 {
    font-size: 2.5rem;
    letter-spacing: -1px;
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px;
    display: flex;
    gap: 40px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
}

.sidebar-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}

.cart-summary {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex: 1;
}

/* Search Bar */
.search-bar {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    padding: 6px;
    border-radius: var(--radius-full);
    margin-bottom: 40px;
    box-shadow: var(--shadow-sm);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 1.1rem;
    color: var(--text-main);
}

.search-input:focus {
    box-shadow: none;
}

.search-bar .btn {
    padding: 10px 32px;
    border-radius: var(--radius-full);
}

/* Toolbar & Filters */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 4px;
    display: flex;
    gap: 2px;
}

.view-toggle .btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.view-toggle .btn.active {
    background: var(--bg-input);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
}

.file-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.file-thumbnail {
    height: 200px;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.file-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.file-card:hover .file-thumbnail img {
    transform: scale(1.05);
}

.file-info {
    padding: 20px;
    flex-grow: 1;
}

.file-name {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-actions {
    background: var(--bg-surface);
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 10px;
}

.file-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* Folder Card */
.folder-card {
    height: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.folder-card:hover {
    background: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.folder-icon {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 16px;
    opacity: 0.9;
}

.folder-name {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 600;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #181818;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.modal-large {
    max-width: 900px;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 32px;
    max-height: 80vh;
    overflow-y: auto;
}

/* File Details Modal Specifics */
.file-details-image {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.file-details-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.file-details-label {
    width: 140px;
    font-weight: 600;
    color: var(--primary-color);
}

.file-details-value {
    flex: 1;
    color: var(--text-secondary);
}

/* Floating Action Bar */
.floating-action-bar {
    position: fixed;
    /* Respect iOS home indicator safe-area */
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    /* Fully hide off-screen when not visible */
    transform: translateX(-50%) translateY(calc(220px + env(safe-area-inset-bottom, 0px)));
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}

.floating-action-bar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.selected-count {
    font-weight: 600;
    color: var(--text-main);
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        padding: 20px;
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .hero-section {
        padding: 40px 20px;
    }
}

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

    .navbar {
        padding: 0 20px;
    }

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

/* 
   ----------------
   Admin Panel 
   ----------------
*/
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.admin-header {
    margin-bottom: 40px;
}

.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.user-table {
    width: 100%;
    border-collapse: collapse;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.table-scroll .user-table {
    min-width: 860px;
}

.table-scroll .user-table th,
.table-scroll .user-table td {
    white-space: nowrap;
}

.user-table th,
.user-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.user-table th {
    background-color: var(--bg-surface);
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-manager {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-user {
    background-color: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 900px) {
    .admin-container {
        padding: 20px 12px;
    }

    .admin-section {
        padding: 16px;
    }

    .navbar {
        padding: 12px;
        height: auto;
        min-height: 64px;
        gap: 10px;
        align-items: flex-start;
    }

    .navbar-brand h1 {
        font-size: 1rem;
        margin: 0;
        line-height: 1.2;
    }

    .navbar-user {
        padding: 6px 12px;
        gap: 10px;
    }

    .nav-link {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 28px;
    }

    .modal {
        padding: 12px;
    }

    .modal-body {
        padding: 18px;
        max-height: 75vh;
    }
}

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

    .table-scroll .user-table {
        min-width: 720px;
    }
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Navbar Logo Sizing */
.navbar-logo {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
    /* Ensure white logo on dark theme */
}

/* Import Area Styles */
.import-preview {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1) !important;
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #60a5fa !important;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171 !important;
}

/* 
   ----------------
   List View 
   ----------------
*/
.file-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-grid.list-view .file-card {
    flex-direction: row;
    align-items: center;
    height: 72px;
    padding: 0 16px;
}

.file-grid.list-view .folder-card {
    flex-direction: row;
    align-items: center;
    height: 72px;
    padding: 0 24px;
    justify-content: flex-start;
    gap: 20px;
}

.file-grid.list-view .folder-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
}

.file-grid.list-view .folder-name {
    font-size: 1rem;
    flex-grow: 1;
    text-align: left;
}

.file-grid.list-view .folder-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-grid.list-view .file-thumbnail {
    width: 48px;
    height: 48px;
    padding: 0;
    border-bottom: none;
    border-radius: var(--radius-sm);
    margin-right: 16px;
    background: transparent;
    flex-shrink: 0;
}

.file-grid.list-view .file-info {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.file-grid.list-view .file-name {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.file-grid.list-view .file-meta {
    margin-left: auto;
    margin-right: 20px;
}

.file-grid.list-view .file-actions {
    background: transparent;
    border-top: none;
    padding: 0;
    width: auto;
    opacity: 0;
    /* Hide actions until hover */
    transition: opacity 0.2s;
}

.file-grid.list-view .file-card:hover .file-actions {
    opacity: 1;
}

.file-grid.list-view .file-actions .btn {
    padding: 6px 12px;
    font-size: 0.7rem;
}

/* File Icons (Missing styles) */
.file-thumbnail-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--text-secondary);
}

.file-thumbnail-icon.pdf {
    color: #ef4444;
    /* Red for PDF */
}

.file-thumbnail-icon.video {
    color: #3b82f6;
    /* Blue for Video */
}

.file-thumbnail-icon.generic {
    color: var(--text-muted);
}

/* Folder Navigation Bar */
.folder-nav {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-surface) !important;
    /* Force override inline styles */
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light) !important;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 1rem;
    grid-column: 1 / -1;
    width: 100%;
}

/* File Actions Panel (Modal) */
.file-actions-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.folder-nav h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}
