/* =============================================================
   jbstorage.eu - Design System
   ============================================================= */

:root {
    --color-primary: #1C69D4;
    --color-primary-dark: #0F4FAB;
    --color-primary-light: #E8F1FD;
    --color-accent: #0066B1;

    --color-bg: #F7F8FA;
    --color-bg-alt: #FFFFFF;
    --color-surface: #FFFFFF;
    --color-border: #E4E7EC;
    --color-border-strong: #D0D5DD;

    --color-text: #101828;
    --color-text-muted: #667085;
    --color-text-light: #98A2B3;

    --color-success: #12B76A;
    --color-error:   #D92D20;
    --color-warning: #DC6803;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow:    0 4px 12px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

    --sidebar-width: 280px;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfMZhrib2Bg-4.woff2') format('woff2');
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.skip-link {
    position: absolute; top: -200px; left: 8px;
    background: var(--color-primary); color: #fff;
    padding: 8px 16px; border-radius: var(--radius-sm);
    z-index: 9999;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--color-text-muted); font-weight: 400; }

/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border: 1px solid transparent;
    border-radius: var(--radius); background: transparent;
    color: var(--color-text); cursor: pointer;
    font: 500 14px/1.2 var(--font);
    transition: all .15s ease;
    white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--color-bg); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary {
    background: var(--color-primary); color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

.btn-secondary {
    background: #fff; color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.btn-danger:hover { filter: brightness(.92); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* =============================================================
   FORMS / ALERTS
   ============================================================= */
label {
    display: block;
    font-weight: 500; font-size: 13px;
    margin-bottom: 14px; color: var(--color-text);
}
label.checkbox {
    display: flex; gap: 10px; align-items: flex-start;
    font-weight: 400; line-height: 1.4;
}

input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius); background: #fff;
    font: 400 14px/1.4 var(--font);
    color: var(--color-text);
    margin-top: 6px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(28, 105, 212, .12);
}

.alert {
    padding: 12px 14px; border-radius: var(--radius);
    margin-bottom: 14px; font-size: 14px;
    border: 1px solid;
}
.alert-error   { background: #FEF3F2; border-color: #FDA29B; color: #B42318; }
.alert-success { background: #ECFDF3; border-color: #6CE9A6; color: #027A48; }

/* =============================================================
   AUTH PAGES (Login / Register / Verify)
   ============================================================= */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(60% 50% at 20% 20%, rgba(28, 105, 212, .14), transparent),
        radial-gradient(40% 40% at 80% 80%, rgba(0, 102, 177, .12), transparent),
        var(--color-bg);
}
.auth-card {
    width: 100%; max-width: 440px;
    background: #fff;
    padding: 36px 36px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.auth-sub { color: var(--color-text-muted); margin: 0 0 24px; }

.auth-logo {
    display: inline-flex; align-items: center; gap: 10px;
    margin-bottom: 24px; text-decoration: none;
}
.logo-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    box-shadow: 0 4px 12px rgba(28, 105, 212, .35);
    position: relative;
}
.logo-mark::before, .logo-mark::after {
    content: ''; position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
}
.logo-mark::before { width: 16px; height: 4px; border-radius: 2px; box-shadow: 0 -6px 0 #fff, 0 6px 0 #fff; }

.logo-text {
    font-weight: 700; font-size: 20px;
    color: var(--color-text); letter-spacing: -.02em;
}

.auth-alt { text-align: center; color: var(--color-text-muted); margin: 18px 0 0; font-size: 14px; }

/* =============================================================
   APP SHELL (Dashboard)
   ============================================================= */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--color-border);
    padding: 20px 16px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
}
.sidebar-head { margin-bottom: 24px; }
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    text-decoration: none;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar-nav hr {
    border: none; border-top: 1px solid var(--color-border);
    margin: 12px -4px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    color: var(--color-text);
    border-radius: var(--radius);
    font-weight: 500; font-size: 14px;
    text-decoration: none;
    transition: background .12s;
}
.sidebar-link:hover { background: var(--color-bg); text-decoration: none; }
.sidebar-link.is-active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.quota-box {
    margin: 16px 0;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius);
}
.quota-label {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--color-text-muted);
    margin-bottom: 6px; font-variant-numeric: tabular-nums;
}
.quota-bar {
    height: 6px; background: #fff;
    border-radius: 4px; overflow: hidden;
    border: 1px solid var(--color-border);
}
.quota-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transition: width .3s;
}

.sidebar-foot {
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid var(--color-border);
    display: flex; align-items: center; gap: 10px;
}
.user-block { display: flex; gap: 10px; align-items: center; min-width: 0; flex: 1; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-info strong {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info small {
    font-size: 11px; color: var(--color-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logout-link {
    color: var(--color-text-muted); padding: 8px;
    border-radius: var(--radius);
}
.logout-link:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.logout-link svg { width: 18px; height: 18px; display: block; }

/* =============================================================
   CONTENT AREA
   ============================================================= */
.content { padding: 24px 32px 80px; min-width: 0; }

.content-head {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 24px; flex-wrap: wrap;
}

.breadcrumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; flex-wrap: wrap; }
.crumb {
    color: var(--color-text-muted);
    font-weight: 500; font-size: 15px;
    padding: 4px 8px; border-radius: var(--radius-sm);
}
.crumb:last-child { color: var(--color-text); }
.crumb:hover { background: var(--color-bg); text-decoration: none; }
.crumb-sep { color: var(--color-text-light); }

.search-wrap {
    position: relative; flex: 0 1 320px;
}
.search-wrap svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--color-text-muted);
    pointer-events: none;
}
.search-wrap input {
    margin: 0; padding-left: 38px;
}

.view-toggle {
    display: flex; background: #fff;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius); overflow: hidden;
}
.vt-btn {
    padding: 8px 10px; background: none; border: none;
    color: var(--color-text-muted); cursor: pointer;
    transition: all .12s;
}
.vt-btn svg { width: 18px; height: 18px; display: block; }
.vt-btn:hover { background: var(--color-bg); }
.vt-btn.is-active { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* =============================================================
   DROPZONE & BROWSER
   ============================================================= */
.dropzone { position: relative; min-height: 60vh; }

.dropzone-hint {
    position: absolute; inset: 0;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(28, 105, 212, .04);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-lg);
    color: var(--color-primary-dark);
    pointer-events: none; z-index: 10;
}
.dropzone-hint svg { width: 56px; height: 56px; opacity: .6; margin-bottom: 12px; }
.dropzone.is-dragover .dropzone-hint { display: flex; }

.browser.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.browser.view-list { display: flex; flex-direction: column; gap: 4px; }

.loading {
    grid-column: 1 / -1;
    text-align: center; padding: 60px 20px;
    color: var(--color-text-muted);
}
.empty {
    grid-column: 1 / -1;
    text-align: center; padding: 80px 20px;
    color: var(--color-text-muted);
}
.empty h3 { margin: 12px 0 6px; color: var(--color-text); }
.empty p { margin: 0; }

/* CARD (Grid-View) */
.item-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all .12s;
    display: flex; flex-direction: column; gap: 10px;
    position: relative;
}
.item-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--color-primary-light);
    transform: translateY(-2px);
}
.item-icon {
    width: 56px; height: 56px;
    border-radius: var(--radius);
    background: var(--color-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-primary);
}
.item-icon svg { width: 30px; height: 30px; }
.item-icon[data-icon="folder"]  { background: #EFF8FF; color: #1570EF; }
.item-icon[data-icon="image"]   { background: #FDF2FA; color: #C11574; }
.item-icon[data-icon="text"]    { background: #F0F9FF; color: #0086C9; }
.item-icon[data-icon="archive"] { background: #FFFAEB; color: #B54708; }
.item-icon[data-icon="pdf"]     { background: #FEF3F2; color: #B42318; }
.item-icon[data-icon="doc"]     { background: #EFF8FF; color: #1570EF; }
.item-icon[data-icon="xls"]     { background: #ECFDF3; color: #027A48; }
.item-icon[data-icon="ppt"]     { background: #FFF6ED; color: #C4320A; }
.item-icon[data-icon="audio"]   { background: #F4F3FF; color: #5925DC; }
.item-icon[data-icon="video"]   { background: #FDF2FA; color: #C11574; }

.item-name {
    font-size: 14px; font-weight: 500;
    color: var(--color-text);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.item-meta {
    font-size: 12px; color: var(--color-text-muted);
    display: flex; justify-content: space-between; gap: 8px;
    font-variant-numeric: tabular-nums;
}
.item-star {
    position: absolute; top: 10px; right: 10px;
    width: 28px; height: 28px;
    background: none; border: none; cursor: pointer;
    color: var(--color-text-light);
    opacity: 0; transition: all .12s;
    border-radius: 50%;
}
.item-card:hover .item-star { opacity: 1; }
.item-star:hover { background: var(--color-bg); }
.item-star.is-active { opacity: 1; color: #F79009; }
.item-star svg { width: 16px; height: 16px; display: block; margin: 0 auto; }

/* LIST View */
.browser.view-list .item-card {
    flex-direction: row; align-items: center; padding: 8px 12px;
    border-color: transparent;
}
.browser.view-list .item-card:hover { background: var(--color-bg); transform: none; box-shadow: none; }
.browser.view-list .item-icon { width: 36px; height: 36px; flex-shrink: 0; }
.browser.view-list .item-icon svg { width: 20px; height: 20px; }
.browser.view-list .item-name { flex: 1; }
.browser.view-list .item-meta { flex: 0 0 auto; flex-direction: row; gap: 16px; }
.browser.view-list .item-star { position: static; opacity: 1; }

/* =============================================================
   MODAL
   ============================================================= */
.modal {
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, .55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
    background: #fff; border-radius: var(--radius-lg);
    width: 100%; max-width: 480px;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    max-height: 90vh;
}
.modal-lg { max-width: 960px; }
.modal-head {
    padding: 16px 20px; border-bottom: 1px solid var(--color-border);
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.modal-head h3 {
    margin: 0; font-size: 16px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.modal-actions { display: flex; gap: 8px; align-items: center; }
.modal-close {
    width: 36px; height: 36px; padding: 0; line-height: 1;
    background: none; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 24px;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    display: flex; justify-content: flex-end; gap: 8px;
}

.preview-text {
    background: #0F172A; color: #E2E8F0;
    padding: 16px; border-radius: var(--radius);
    font: 400 13px/1.6 var(--font-mono);
    white-space: pre-wrap; word-break: break-word;
    max-height: 70vh; overflow: auto;
}
.preview-image {
    text-align: center; max-height: 75vh; overflow: auto;
}
.preview-image img { max-width: 100%; max-height: 75vh; border-radius: var(--radius); }
.preview-pdf iframe {
    width: 100%; height: 70vh; border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.preview-empty {
    text-align: center; padding: 40px;
    color: var(--color-text-muted);
}
.preview-zip { max-height: 70vh; overflow: auto; }
.zip-entry {
    display: grid; grid-template-columns: 1fr auto auto;
    gap: 12px; padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px; align-items: center;
}
.zip-entry:hover { background: var(--color-bg); }
.zip-entry-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--font-mono);
}
.zip-entry-name.is-dir { font-weight: 600; color: var(--color-primary); }
.zip-entry-meta { color: var(--color-text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.zip-banner {
    margin-bottom: 14px; padding: 12px 14px;
    background: var(--color-primary-light);
    border-radius: var(--radius);
    display: flex; gap: 12px; align-items: center;
}
.zip-banner-text { flex: 1; font-size: 13px; color: var(--color-primary-dark); }

/* =============================================================
   CONTEXT MENU
   ============================================================= */
.context-menu {
    position: fixed; z-index: 2000;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    min-width: 180px;
}
.context-menu[hidden] { display: none; }
.context-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px;
    background: none; border: none;
    text-align: left; cursor: pointer;
    font-size: 14px; color: var(--color-text);
    border-radius: var(--radius-sm);
}
.context-item:hover { background: var(--color-bg); }
.context-item.danger { color: var(--color-error); }
.context-item.danger:hover { background: #FEF3F2; }
.context-item svg { width: 16px; height: 16px; }
.context-sep { height: 1px; background: var(--color-border); margin: 4px 0; }

/* =============================================================
   UPLOAD TRAY
   ============================================================= */
.upload-tray {
    position: fixed; bottom: 24px; right: 24px;
    width: 360px; max-width: calc(100vw - 32px);
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    z-index: 100; overflow: hidden;
}
.upload-tray[hidden] { display: none; }
.upload-tray-head {
    padding: 12px 16px;
    background: var(--color-bg);
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--color-border);
}
.upload-list { max-height: 320px; overflow-y: auto; }
.upload-item {
    padding: 10px 16px; border-bottom: 1px solid var(--color-border);
}
.upload-item:last-child { border-bottom: none; }
.upload-item-row {
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 13px;
    margin-bottom: 6px;
}
.upload-item-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.upload-item-status { color: var(--color-text-muted); font-size: 12px; }
.upload-item-status.success { color: var(--color-success); }
.upload-item-status.error   { color: var(--color-error); }
.upload-progress {
    height: 4px; background: var(--color-bg); border-radius: 2px; overflow: hidden;
}
.upload-progress-bar {
    height: 100%; background: var(--color-primary);
    width: 0; transition: width .2s;
}

/* =============================================================
   FOOTER
   ============================================================= */
.site-footer {
    border-top: 1px solid var(--color-border);
    background: #fff;
    padding: 16px 32px;
    color: var(--color-text-muted);
    font-size: 13px;
}
.app-shell + .site-footer { grid-column: 1 / -1; }
.footer-inner {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap;
}
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-nav a { color: var(--color-text-muted); }
.footer-nav a:hover { color: var(--color-primary); }

/* =============================================================
   COOKIE BANNER
   ============================================================= */
.cookie-banner {
    position: fixed; left: 16px; right: 16px; bottom: 16px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 16px 20px;
    z-index: 500;
}
.cookie-banner-inner {
    display: flex; gap: 16px; align-items: center; max-width: 1200px; margin: 0 auto;
}
.cookie-banner p { margin: 0; font-size: 13px; flex: 1; }

/* =============================================================
   LEGAL PAGES
   ============================================================= */
.legal-wrap {
    max-width: 800px; margin: 40px auto; padding: 32px;
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.legal-wrap h1 { font-size: 28px; margin: 0 0 24px; }
.legal-wrap h2 { font-size: 18px; margin: 28px 0 10px; }
.legal-wrap h3 { font-size: 15px; margin: 18px 0 6px; }
.legal-wrap p, .legal-wrap ul { font-size: 14px; line-height: 1.65; color: #344054; }
.legal-back { margin-bottom: 16px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: relative; height: auto;
        flex-direction: row; flex-wrap: wrap;
        padding: 12px 16px;
    }
    .sidebar-head, .sidebar-nav, .quota-box, .sidebar-foot {
        flex: 1 1 auto;
    }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-nav hr { display: none; }
    .quota-box { width: 100%; }
    .content { padding: 16px; }
    .content-head { flex-direction: column; align-items: stretch; }
    .search-wrap { flex: 1; }
}
