/* ============================================================
   SISTEMA DE TICKETS – LOGÍSTICA
   Stylesheet principal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ───────────────────────────────────────────── */
:root {
    --bg:           #f7f8fa;
    --surface:      #ffffff;
    --sidebar-bg:   #0f1225;
    --sidebar-text: #a0a3bd;
    --sidebar-active: #6c5ce7;
    --primary:      #6c5ce7;
    --primary-soft: rgba(108, 92, 231, 0.1);
    --primary-glow: rgba(108, 92, 231, 0.35);
    --success:      #00b894;
    --success-soft: rgba(0, 184, 148, 0.1);
    --warning:      #fdcb6e;
    --warning-soft: rgba(253, 203, 110, 0.1);
    --danger:       #e74c5e;
    --danger-soft:  rgba(231, 76, 94, 0.1);
    --info:         #0984e3;
    --info-soft:    rgba(9, 132, 227, 0.1);
    --text:         #1e1e2f;
    --text-muted:   #6b7280;
    --border:       #e5e7eb;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    6px;
    --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:    0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:    0 12px 40px rgba(0,0,0,.12);
    --font:         'DM Sans', sans-serif;
    --mono:         'JetBrains Mono', monospace;
    --sidebar-w:    260px;
    --header-h:     64px;
    --transition:   all 0.2s ease;
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

/* ─── LOGIN ───────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1225 0%, #1a1a40 50%, #2d1b69 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    top: -150px; right: -100px;
    border-radius: 50%;
    animation: pulse 6s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(0,184,148,.15), transparent 70%);
    bottom: -100px; left: -50px;
    border-radius: 50%;
    animation: pulse 8s ease-in-out infinite reverse;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: .6; }
    50% { transform: scale(1.15); opacity: 1; }
}

.login-card {
    position: relative;
    z-index: 2;
    background: rgba(255,255,255,.04);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    color: #fff;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,.4));
}

.login-card h1 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -.02em;
}

.login-card .subtitle {
    color: var(--sidebar-text);
    font-size: .92rem;
    margin-bottom: 32px;
}

.login-card .form-group { margin-bottom: 20px; }

.login-card label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--sidebar-text);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: .95rem;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-card input::placeholder { color: rgba(255,255,255,.25); }

.login-card .btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.login-card .btn-login:hover {
    background: #5a4bd1;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.login-error {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: .88rem;
    margin-bottom: 16px;
    display: none;
}

/* ─── LAYOUT ──────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    max-width: 148px;
    height: auto;
    display: block;
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.2);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: .9rem;
    font-weight: 400;
    color: var(--sidebar-text);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
}

.nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

.nav-item .icon {
    width: 20px;
    height: 20px;
    opacity: .7;
    flex-shrink: 0;
}

.nav-item.active .icon { opacity: 1; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.04);
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .82rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-info .name {
    font-size: .85rem;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    font-size: .72rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
}

/* ─── HEADER ──────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
}

.page-header .breadcrumb {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── CARDS ───────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 1.2rem;
}

.stat-card .stat-icon.purple  { background: var(--primary-soft); color: var(--primary); }
.stat-card .stat-icon.green   { background: var(--success-soft); color: var(--success); }
.stat-card .stat-icon.yellow  { background: var(--warning-soft); color: var(--warning); }
.stat-card .stat-icon.red     { background: var(--danger-soft);  color: var(--danger); }
.stat-card .stat-icon.blue    { background: var(--info-soft);    color: var(--info); }

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ─── DASHBOARD ANALYTICS ─────────────────────────────────── */
.dashboard-layout {
    margin-bottom: 24px;
}

.dashboard-main {
    display: block;
}

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi-item {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    border-radius: 12px;
    padding: 12px 14px;
}

.kpi-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

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

.analytics-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--surface);
}

.panel-title {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.funnel-row,
.origin-row {
    margin-bottom: 10px;
}

.funnel-meta,
.origin-meta {
    display: flex;
    justify-content: space-between;
    font-size: .83rem;
    margin-bottom: 5px;
}

.funnel-meta strong,
.origin-meta strong {
    font-weight: 700;
}

.funnel-bar,
.origin-bar {
    height: 8px;
    width: 100%;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.funnel-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6c5ce7, #4facfe);
}

.origin-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #00b894, #55efc4);
}

.provider-row,
.activity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}

.provider-row:last-child,
.activity-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.provider-name,
.activity-ticket {
    font-size: .88rem;
    font-weight: 600;
}

.provider-sub,
.activity-sub {
    font-size: .76rem;
    color: var(--text-muted);
}

.provider-count {
    min-width: 34px;
    height: 28px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .82rem;
}

/* ─── CARD / PANEL ────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.card-body { padding: 22px; }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: #5a4bd1; box-shadow: 0 4px 14px var(--primary-glow); text-decoration: none; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #00a884; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #d43d4f; }

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

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: .82rem; }

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-xs);
}

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

select.form-control { appearance: none; cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.form-hint {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* File input */
.file-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.file-upload:hover { border-color: var(--primary); background: var(--primary-soft); }

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload .file-label {
    font-size: .88rem;
    color: var(--text-muted);
}

.file-upload .file-label strong { color: var(--primary); }

/* ─── TABLE ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

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

table th, table td {
    padding: 12px 16px;
    text-align: left;
    font-size: .88rem;
    border-bottom: 1px solid var(--border);
}

table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--bg);
    position: sticky;
    top: 0;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: rgba(108,92,231,.03);
}

table td .cell-ticket {
    font-family: var(--mono);
    font-weight: 500;
    font-size: .82rem;
    color: var(--primary);
}

/* ─── BADGES ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.badge-pending   { background: var(--warning-soft); color: #e17f28; }
.badge-accepted  { background: var(--success-soft); color: var(--success); }
.badge-assigned  { background: var(--info-soft);    color: var(--info); }
.badge-rejected  { background: var(--danger-soft);  color: var(--danger); }
.badge-completed { background: rgba(108,92,231,.1); color: var(--primary); }
.badge-bodega    { background: var(--info-soft);    color: var(--info); }
.badge-compras   { background: rgba(253,203,110,.15); color: #d4a017; }

/* ─── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .25s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ─── TOAST NOTIFICATIONS ─────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-md);
    animation: slideInRight .3s ease, fadeOut .3s ease 3.5s forwards;
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ─── FILTERS BAR ─────────────────────────────────────────── */
.filters-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar .form-control {
    width: auto;
    min-width: 160px;
}

/* ─── TICKET DETAIL ───────────────────────────────────────── */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.detail-item {
    padding: 10px 0;
}

.detail-item .detail-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 3px;
}

.detail-item .detail-value {
    font-size: .95rem;
    font-weight: 500;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px; top: 4px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

.timeline-item .tl-action {
    font-weight: 600;
    font-size: .88rem;
}

.timeline-item .tl-details {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.timeline-item .tl-meta {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--mono);
}

/* ─── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: .4;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

/* ─── LOADING ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius);
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-analytics-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .login-card { width: 100%; margin: 16px; padding: 32px 24px; }

    .mobile-toggle {
        display: flex !important;
        position: fixed;
        top: 16px; left: 16px;
        z-index: 101;
        background: var(--sidebar-bg);
        color: #fff;
        border: none;
        padding: 10px;
        border-radius: var(--radius-sm);
        cursor: pointer;
    }
}

.mobile-toggle { display: none; }

/* ─── UTILITIES ───────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ─── FARM ROWS (Nuevo Ticket) ────────────────────────────── */
.farm-row {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px 6px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.farm-row:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

#farms-container:empty::after {
    content: 'No se han agregado granjas. Pulse "Añadir granja" para comenzar.';
    display: block;
    text-align: center;
    color: var(--text-muted);
    font-size: .88rem;
    padding: 20px;
}

/* ─── SEARCHABLE SELECT ──────────────────────────────────── */
.ss-wrapper {
    position: relative;
}

.ss-input {
    cursor: pointer;
}

.ss-input:focus {
    cursor: text;
}

.ss-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1100;
    box-shadow: var(--shadow-md);
}

.ss-dropdown.ss-open {
    display: block;
}

.ss-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: .875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
}

.ss-option:last-child {
    border-bottom: none;
}

.ss-option:hover,
.ss-option.ss-focused {
    background: var(--primary-soft);
    color: var(--primary);
}

.ss-option.ss-selected {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.ss-option.ss-empty {
    color: var(--text-muted);
    cursor: default;
    font-style: italic;
}

.ss-option.ss-empty:hover {
    background: none;
    color: var(--text-muted);
}

/* ─── EMAIL SETTINGS TABS ────────────────────────────────── */
.email-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px;
    overflow-x: auto;
}

.email-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.email-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.email-tab.active {
    background: var(--primary);
    color: #fff;
}

.email-tab svg {
    flex-shrink: 0;
}

/* Email log pagination */
.email-log-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.email-log-pagination button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ─── ROLES & PERMISSIONS MATRIX ─────────────────────────── */
.perm-group {
    margin-bottom: 16px;
}

.perm-group-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.perm-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.perm-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.perm-check:hover {
    background: var(--primary-soft);
}

.perm-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .perm-checks {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .email-tabs {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .email-tab {
        padding: 8px 14px;
        font-size: .82rem;
    }
}

