﻿/* ===============================
   RESET / BASE
================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ===============================
   VARIABLES
================================= */
:root {
    --bg: #eef2f6;
    --panel: #ffffff;
    --panel-soft: #e9eef5;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-soft: #dbeafe;
    --success: #15803d;
    --warning: #d97706;
    --danger: #b91c1c;
    --border: #d6dde6;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 3px 8px rgba(0,0,0,0.05);
    --touch: 48px;
}

/* ===============================
   LAYOUT
================================= */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ===============================
   HEADER
================================= */
.app-header {
    background: linear-gradient(90deg, #264781 0%, #2563eb 34%, #005932 100%);
    color: white;
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===============================
   BRAND
================================= */
.app-left {
    display: flex;
    align-items: center;
    height: 100%;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.app-logo-frame {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.app-logo-frame-llopart {
    width: 235px;
    justify-content: flex-start;
    border-radius: 5px;
}

.app-logo-frame-titu {
    width: 112px;
}

.app-logo-frame-docks {
    width: 112px;
}

.app-brand-login .app-logo-frame-titu {
    width: 150px;
    justify-content: flex-start;
}

.app-logo {
    display: block;
    height: 100%;
    width: auto;
    object-fit: contain;
}

.app-logo-llopart {
    max-width: 100%;
    height: 39px;
    transform: none;
}

.app-logo-titu {
    max-width: 100%;
}

.app-logo-docks {
    max-width: 100%;
}

.app-brand-separator {
    width: 1px;
    height: 34px;
    background: rgba(255,255,255,0.32);
    flex: 0 0 auto;
}

@media (max-width: 760px) {
    .app-header {
        padding: 0 12px;
    }

    .app-brand {
        gap: 8px;
    }

    .app-logo-frame {
        height: 42px;
    }

    .app-logo-frame-llopart {
        width: 170px;
    }

    .app-logo-frame-titu {
        width: 94px;
    }

    .app-logo-frame-docks {
        width: 88px;
    }

    .app-brand-separator {
        height: 28px;
    }
}

@media (max-width: 560px) {
    .nav-user-name {
        display: none;
    }

    .app-logo-frame-llopart {
        width: 132px;
    }

    .app-logo-frame-titu {
        width: 72px;
    }

    .app-logo-frame-docks {
        width: 70px;
    }
}

/* ===============================
   NAV
================================= */
.app-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ===============================
   USER (PLANO)
================================= */
.nav-user-name {
    font-size: 14px;
    font-weight: 500;
    color: white;
    opacity: 0.9;
}

.mode-switch-form {
    margin: 0;
}

.mode-switch {
    height: 32px;
    min-width: 118px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.mode-switch.mode-prod {
    background: rgba(22,101,52,0.65);
}

.mode-switch.mode-test {
    background: rgba(185,28,28,0.85);
}

.test-mode-banner {
    background: #b91c1c;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0;
    padding: 10px 18px;
    text-align: center;
    text-transform: uppercase;
}

/* ===============================
   MENU BUTTON
================================= */
.menu-dropdown {
    position: relative;
}

.menu-toggle {
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 18px;
    background: rgba(255,255,255,0.15);
    transition: background 0.15s ease;
}

    .menu-toggle:hover {
        background: rgba(255,255,255,0.25);
    }

/* ===============================
   DROPDOWN
================================= */
.menu-panel {
    position: absolute;
    top: 110%;
    right: 0;
    min-width: 180px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

.menu-item {
    padding: 12px 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
}

    .menu-item:hover {
        background: var(--panel-soft);
    }

.menu-separator {
    height: 1px;
    background: var(--border);
}

.menu-item.logout {
    color: var(--danger);
}

.menu-dropdown.open .menu-panel {
    display: flex;
}

/* ===============================
   MAIN
================================= */
.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ===============================
   CARDS
================================= */
.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

    .card + .card {
        margin-top: 12px;
    }

/* ===============================
   BUTTONS
================================= */
.btn {
    min-height: var(--touch);
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 16px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover,
.btn:focus {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: var(--panel-soft);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn:active {
    transform: scale(0.98);
}

/* ===============================
   INPUTS
================================= */
.input {
    width: 100%;
    min-height: var(--touch);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 16px;
    background: white;
}

input[type="file"].input {
    padding: 8px 12px;
}

input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-right: 12px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    background: #1e40af;
}

.file-choice-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.file-choice-item,
.file-choice-stack {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.file-choice-item span,
.file-choice-caption {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.file-choice-item input[type="file"],
.file-choice-stack input[type="file"] {
    width: 100%;
}

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

    .input:focus {
        outline: 2px solid var(--primary-soft);
    }

/* ===============================
   GRID
================================= */
.grid {
    display: grid;
    gap: 12px;
}

/* ===============================
   SHARED PAGE STRUCTURE
================================= */
.page-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-toolbar,
.form-header,
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.page-subtitle {
    color: var(--muted);
    font-size: 14px;
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    flex: 1;
    min-height: 0;
}

.card-footer,
.panel-footer,
.actions,
.actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.card-footer,
.panel-footer {
    margin-top: 14px;
}

.form-grid .panel-footer,
.form-grid-2 .panel-footer,
.form-grid-3 .panel-footer,
.form-grid-compact .panel-footer {
    grid-column: 1 / -1;
}

/* ===============================
   SHARED FORMS
================================= */
.form-panel {
    max-width: 420px;
}

.form-panel-wide {
    max-width: 760px;
}

.form-grid,
.form-vertical {
    display: grid;
    gap: 10px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid-3,
.form-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.row-inline {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.field,
.file-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label,
.file-field label,
.field-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: white;
    font-size: 14px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

.field.checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.permission-group {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

/* ===============================
   SHARED TABLES
================================= */
.table-wrapper {
    width: 100%;
    overflow: auto;
    position: relative;
}

.table-scrollbar-x {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    margin-bottom: 8px;
}

.table-scrollbar-x.is-hidden {
    display: none;
}

.table-scrollbar-x > div {
    height: 1px;
}

.data-table,
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead,
.table thead {
    background: var(--panel-soft);
}

.data-table th,
.data-table td,
.table th,
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th,
.table th {
    color: var(--muted);
    font-weight: 600;
}

.data-table tbody tr:hover,
.table tbody tr:hover {
    background: #f8fafc;
}

.actions-col {
    width: 110px;
    text-align: right;
}

.actions-col form {
    margin: 0;
}

.customer-item-photo-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.customer-item-photo-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
}

/* ===============================
   SHARED STATUS / MESSAGES
================================= */
.alert {
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.alert.success {
    background: #ecfdf5;
    color: var(--success);
}

.alert.error {
    background: #fef2f2;
    color: var(--danger);
}

.alert.warning {
    background: #fff7ed;
    color: var(--warning);
}

.tag,
.pill,
.photo-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.pill,
.photo-chip {
    border-radius: 999px;
}

.tag {
    max-width: min(220px, 100%);
    min-width: 64px;
    border-radius: var(--radius-sm);
    justify-content: center;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.tag,
.pill {
    padding: 4px 8px;
}

.data-table .tag,
.table .tag {
    vertical-align: middle;
}

@media (max-width: 760px) {
    .tag {
        min-width: 0;
        max-width: 180px;
    }
}

.photo-chip {
    padding: 5px 9px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid rgba(29,78,216,0.15);
}

.tag.ok {
    background: #d1fae5;
    color: var(--success);
}

.tag.blocked,
.tag.warning,
.tag.warn {
    background: #fed7aa;
    color: var(--warning);
}

.tag.inactive {
    background: #e5e7eb;
    color: #475569;
}

.tag.danger {
    background: #fee2e2;
    color: var(--danger);
}

/* ===============================
   BUTTON ALIASES
================================= */
.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.secondary {
    background: var(--panel-soft);
    color: var(--text);
}

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

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

.btn-sm,
.btn.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

/* ===============================
   SCROLL
================================= */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}


/* ===============================
   MENU GROUPS (ESTILO FINAL)
================================= */

.menu-group {
    padding: 8px 0;
}

/* TITULO AZUL */
.menu-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    padding: 6px 14px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* LINEA SEPARADORA */
.menu-group + .menu-group {
    border-top: 1px solid var(--border);
}

/* ITEMS EN GRIS */
.menu-item {
    padding: 10px 14px;
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
    display: block;
    transition: all 0.15s ease;
}

    /* HOVER */
    .menu-item:hover {
        background: var(--primary-soft);
        color: var(--primary);
    }

    /* LOGOUT */
    .menu-item.logout {
        color: var(--danger);
    }

        .menu-item.logout:hover {
            background: rgba(220,38,38,0.1);
        }
