/* ==========================================================================
   Comercial Godó — Gestor Documental
   Responsive webapp: primary #0097F0 · secondary #2479aa · accent #f98133
   ========================================================================== */

/* ---------- CSS Variables ---------- */
:root {
    --primary: #0097F0;
    --primary-dark: #007acc;
    --secondary: #2479aa;
    --accent: #f98133;
    --accent-hover: #e0712a;
    --bg: #f4f7fa;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
    --transition: .2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --container: 1200px;
    --header-h: 64px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ---------- Container ---------- */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.site-header {
    background: var(--secondary);
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
}
.site-logo img {
    height: 38px;
    width: auto;
    display: block;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.site-nav > a, .site-nav > .nav-user {
    color: rgba(255,255,255,.85);
    font-weight: 500;
    font-size: .9rem;
    padding: .5rem .85rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: all var(--transition);
    white-space: nowrap;
}
.site-nav > a:hover, .site-nav > a.active {
    color: #fff;
    background: rgba(255,255,255,.12);
}
.site-nav > a .material-icons-outlined { font-size: 1.15rem; }
.nav-user {
    color: rgba(255,255,255,.85);
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.nav-user .material-icons-outlined { font-size: 1.2rem; }
.nav-user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 5px;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all .3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 90;
}
.mobile-overlay.show { display: block; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.4rem;
    font-weight: 600;
    font-size: .9rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn .material-icons-outlined { font-size: 1.1rem; color: inherit; }

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

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

/* Header variant: solid orange, slightly transparent on hover */
.site-nav .btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.site-nav .btn-accent:hover {
    background: var(--accent);
    opacity: .82;
    color: #fff;
    border-color: var(--accent);
}

.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-outline:hover { background: rgba(255,255,255,.1); color: #fff; border-color: #fff; }

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

.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ==========================================================================
   MAIN
   ========================================================================== */
.site-main {
    flex: 1;
    padding: 2rem 0;
}

/* ==========================================================================
   TOOLBAR (Search + Counter)
   ========================================================================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.toolbar-left {
    display: flex;
    align-items: baseline;
    gap: .75rem;
}
.toolbar-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
.toolbar-count {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
}
.toolbar-search {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: .4rem .85rem;
    gap: .4rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    max-width: 300px;
    width: 100%;
}
.toolbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,151,240,.1);
}
.toolbar-search-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
}
.toolbar-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: .88rem;
    color: var(--text);
    min-width: 0;
}
.toolbar-search input::placeholder { color: var(--text-muted); }
.toolbar-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.toolbar-search-clear .material-icons-outlined {
    font-size: 1.05rem;
}
.toolbar-search-clear:hover {
    color: var(--text-light);
}

/* ==========================================================================
   PRODUCT TABLE (Home)
   ========================================================================== */
.product-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.product-table thead {
    background: var(--border-light);
}
.product-table th {
    text-align: left;
    padding: .65rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.product-table td {
    padding: .7rem 1rem;
    border-top: 1px solid var(--border);
    font-size: .9rem;
    vertical-align: middle;
}
.product-row {
    cursor: pointer;
    transition: background var(--transition);
}
.product-row:hover {
    background: rgba(0,151,240,.03);
}
.product-row-link {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}
.product-row:hover .product-row-link {
    color: var(--primary);
}
.product-code-tag {
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(0,151,240,.08);
    padding: .15rem .5rem;
    border-radius: 4px;
    white-space: nowrap;
}
.col-code { width: 100px; }
.col-types { width: 260px; }
.col-count { width: 60px; text-align: center; }
.product-table .col-count { font-weight: 600; color: var(--text-light); }

.table-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-top: .9rem;
}

.table-pagination-count {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Badge lock icon (inside type badge for private types) */
.badge-lock-icon {
    font-size: .75rem !important;
    vertical-align: middle;
    margin-right: .1rem;
}
.badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .5rem;
    font-size: .7rem;
    font-weight: 600;
    border-radius: 4px;
    letter-spacing: .02em;
    gap: .15rem;
}
.badge-fds { background: #dbeafe; color: #1d4ed8; }
.badge-etv { background: #fef3c7; color: #92400e; }
.badge-prl { background: #d1fae5; color: #065f46; }

/* Doc type label (next to badge in detail table) */
.doc-type-label {
    margin-left: .4rem;
    font-size: .82rem;
    color: var(--text-light);
    font-weight: 400;
}

/* Locked row (private, not logged in) */
.row-locked {
    opacity: .55;
}
.row-locked:hover {
    opacity: .75;
}
.doc-locked {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: var(--accent);
    font-weight: 500;
    font-size: .85rem;
}
.doc-locked .material-icons-outlined { font-size: 1rem; }

/* No results */
.no-results {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-light);
}
.no-results .material-icons-outlined {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.no-results h3 { margin-bottom: .5rem; color: var(--text); }

/* ==========================================================================
   PRODUCT DETAIL PAGE
   ========================================================================== */
.product-header {
    margin-bottom: 2rem;
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb .material-icons-outlined { font-size: .9rem; }
.product-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.product-title .product-code-tag { font-size: .9rem; }

.doc-section {
    margin-bottom: 2rem;
}
.doc-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--border);
}
.doc-section-title .material-icons-outlined { font-size: 1.3rem; color: var(--primary); }

/* Document table */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.doc-table thead {
    background: var(--border-light);
}
.doc-table th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.doc-table td {
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    font-size: .9rem;
    vertical-align: middle;
}
.doc-table tbody tr:hover { background: rgba(0,151,240,.02); }
.doc-table .doc-type-cell { font-weight: 600; }
.doc-table .doc-download {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: var(--primary);
    font-weight: 500;
    font-size: .85rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.doc-table .doc-download:hover { color: var(--primary-dark); }
.doc-table .doc-download .material-icons-outlined { font-size: 1.1rem; }
.doc-download-form { display: inline; }

/* Private docs locked banner */
.private-lock-banner {
    background: linear-gradient(135deg, rgba(0,151,240,.06), rgba(0,151,240,.02));
    border: 1px dashed var(--primary);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}
.private-lock-banner > .material-icons-outlined {
    font-size: 2.5rem;
    color: var(--primary);
}
.private-lock-banner h3 {
    font-size: 1.1rem;
    color: var(--text);
}
.private-lock-banner p {
    color: var(--text-light);
    font-size: .9rem;
    max-width: 400px;
}
.private-lock-banner .btn-group {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: .5rem;
}

/* ==========================================================================
   FORMS (Login / Solicitar Acceso)
   ========================================================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-h) - 200px);
    padding: 2rem 0;
}
.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}
.auth-card.wide { max-width: 540px; }
.auth-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: .25rem;
}
.auth-card-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: .9rem;
    margin-bottom: 1.75rem;
}
.form-group {
    margin-bottom: 1.15rem;
}
.form-group label {
    display: block;
    margin-bottom: .35rem;
    font-weight: 500;
    font-size: .88rem;
    color: var(--text);
}
.form-group label .required { color: var(--danger); }
.form-control {
    width: 100%;
    padding: .7rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,151,240,.12);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .25rem;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-separator {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 1.25rem 0 .75rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

/* Alert messages */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.alert .material-icons-outlined { font-size: 1.2rem; flex-shrink: 0; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Auth footer links */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.auth-footer a {
    display: block;
    color: var(--text-light);
    font-size: .9rem;
    margin-bottom: .5rem;
}
.auth-footer a:hover { color: var(--primary); }
.auth-footer a.accent { color: var(--accent); font-weight: 600; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
    background: var(--secondary);
    color: rgba(255,255,255,.8);
    padding: 2rem 0;
    margin-top: auto;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.footer-logo {
    height: 30px;
    width: auto;
    opacity: .9;
}
.footer-brand p { font-size: .85rem; }
.footer-links {
    display: flex;
    gap: 1.5rem;
}
.footer-links a {
    color: rgba(255,255,255,.7);
    font-size: .85rem;
    transition: color var(--transition);
}
.footer-links a:hover { color: #fff; }
.footer-copy {
    width: 100%;
    text-align: center;
    font-size: .78rem;
    color: rgba(255,255,255,.5);
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    margin-top: .5rem;
}

/* ==========================================================================
   404 PAGE
   ========================================================================== */
.error-page {
    text-align: center;
    padding: 5rem 1rem;
}
.error-page .material-icons-outlined {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.error-page h1 {
    font-size: 2rem;
    margin-bottom: .5rem;
}
.error-page p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    :root { --header-h: 56px; }

    .hamburger { display: flex; }

    .site-nav {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        background: var(--secondary);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 1.5rem 1rem;
        padding-top: calc(var(--header-h) + 1rem);
        z-index: 95;
        transition: right .3s ease;
        box-shadow: -4px 0 20px rgba(0,0,0,.2);
    }
    .site-nav.open { right: 0; }
    .site-nav > a, .site-nav > .nav-user {
        padding: .85rem 1rem;
        font-size: 1rem;
        border-radius: var(--radius-sm);
    }
    .nav-user {
        flex-direction: column;
        align-items: flex-start;
        gap: .5rem;
    }
    .nav-user .btn { width: 100%; justify-content: center; margin-top: .25rem; }

    .toolbar { flex-direction: column; align-items: stretch; gap: .75rem; }
    .toolbar-search { max-width: 100%; }

    /* Tables scroll on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1.25rem;
        padding: 0 1.25rem;
    }
    .product-table, .doc-table { min-width: 500px; }

    .form-row { grid-template-columns: 1fr; }
    .auth-card { padding: 1.75rem 1.25rem; margin: 0 .5rem; }

    .footer-inner { flex-direction: column; text-align: center; }
    .footer-brand { flex-direction: column; }
    .footer-links { flex-direction: column; gap: .75rem; }
}

@media (max-width: 480px) {
    .product-card { padding: 1rem; }
    .search-section { padding: 1.5rem 0; }
    .auth-card { padding: 1.5rem 1rem; }
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
