/* ── Fuente corporativa LEG Technologies ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Variables de marca LEG ──────────────────────────────────────────────── */
:root {
    --leg-blue:        #1a73e8;
    --leg-blue-dark:   #1558b0;
    --leg-cyan:        #17a5c8;
    --leg-green:       #34c98a;
    --leg-sidebar-bg:  #16263b;
    --leg-sidebar-alt: #1e3250;
    --leg-sidebar-active-bg: rgba(26,133,214,.22);
    --leg-sidebar-active-border: #1a85d6;
    --leg-sidebar-text: #99b3c8;
    --leg-sidebar-section: #4e6a82;
    --leg-content-bg:  #f4f6f9;
    --leg-border:      #e2e8f0;
    --leg-card-shadow: 0 1px 4px rgba(0,0,0,.07);

    /* Gradiente del login — igual que CRM */
    --leg-gradient: linear-gradient(135deg, #1a9bfc 0%, #1ec8a0 55%, #3dd68c 100%);

    --sidebar-width: 205px;
    --bs-font-sans-serif: 'Source Sans 3', 'Source Sans Pro', system-ui, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-font-size: 0.9375rem;
}

*, body {
    font-family: 'Source Sans 3', 'Source Sans Pro', system-ui, sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN — idéntica estética al CRM LEG
═══════════════════════════════════════════════════════════════════════════ */
body.login-page {
    min-height: 100vh;
    background: var(--leg-gradient);
    background-image:
        radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px),
        var(--leg-gradient);
    background-size: 28px 28px, 100% 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.login-card {
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 8px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.07);
    width: 100%;
    max-width: 420px;
    padding: 2.25rem 2.5rem 2rem;
    text-align: center;
}

/* Zona de marca */
.login-brand {
    margin-bottom: 1.75rem;
}

.login-logo-img {
    max-width: 130px;
    height: auto;
    margin: 0 auto .75rem;
    display: block;
}

.login-title {
    font-size: 1.3rem;
    font-weight: 400;
    color: #1a2b45;
    margin-bottom: .2rem;
    letter-spacing: -.01em;
}

.login-subtitle {
    font-size: .875rem;
    color: #8fa3bc;
    margin-bottom: 0;
    font-weight: 400;
}

/* Labels */
.login-card .form-label {
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    text-align: left;
    display: block;
    margin-bottom: .35rem;
}

/* Inputs */
.login-card .input-group-text {
    background: #fff;
    border-color: #d1dbe8;
    color: #b0bec9;
    font-size: .95rem;
}

.login-card .form-control {
    border-color: #d1dbe8;
    background: #fff;
    font-size: .9rem;
    color: #1a2b45;
}

.login-card .form-control::placeholder { color: #b0bec9; }

.login-card .form-control:focus {
    border-color: var(--leg-blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}

.login-card .btn-outline-secondary {
    border-color: #d1dbe8;
    background: #fff;
    color: #b0bec9;
}

.login-card .btn-outline-secondary:hover { background: #f4f6f9; color: #64748b; }

/* Botón Iniciar Sesión — azul sólido igual al CRM */
.btn-login {
    background: #1a85d6;
    border: none;
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    padding: .7rem 1rem;
    border-radius: .5rem;
    width: 100%;
    transition: background .15s, box-shadow .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    cursor: pointer;
    letter-spacing: .01em;
}

.btn-login:hover {
    background: #1570ba;
    color: #fff;
    box-shadow: 0 4px 14px rgba(26,133,214,.35);
}

/* Divisor */
.login-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.5rem 0;
}
.login-divider hr   { flex: 1; margin: 0; border-color: #e8edf2; }
.login-divider span { font-size: .78rem; color: #b0bec9; white-space: nowrap; font-weight: 400; }

/* Botón Microsoft 365 */
.btn-ms365 {
    background: #fff;
    border: 1.5px solid #d1dbe8;
    color: #374151;
    font-size: .9rem;
    font-weight: 600;
    padding: .6rem 1rem;
    border-radius: .5rem;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    text-decoration: none;
}

.btn-ms365:hover {
    border-color: #1a85d6;
    box-shadow: 0 0 0 3px rgba(26,133,214,.1);
    color: #1570ba;
}

/* Pie */
.login-footer-text {
    margin-top: 1.5rem;
    margin-bottom: 0;
    font-size: .72rem;
    color: #b0bec9;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL — igual estética que el CRM
═══════════════════════════════════════════════════════════════════════════ */
body.app-body {
    background: var(--leg-content-bg);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
    background-color: var(--leg-sidebar-bg);
    width: var(--sidebar-width);
    min-height: 100vh;
    transition: width .22s ease, padding .22s ease;
    overflow-x: hidden;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

#sidebar.collapsed {
    width: 0 !important;
    padding: 0 !important;
}

/* Logo en sidebar */
.sidebar-logo-wrap {
    padding: 1rem 1.1rem .75rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-logo-wrap img {
    max-height: 28px;
    width: auto;
    max-width: 140px;
}

/* Secciones del menú */
.sidebar-section-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--leg-sidebar-section);
    padding: .9rem 1rem .25rem;
}

/* Nav links */
.sidebar-nav {
    list-style: none;
    padding: .3rem .6rem;
    margin: 0;
    flex: 1;
}

.sidebar-nav li + li { margin-top: 1px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .7rem;
    border-radius: .4rem;
    font-size: .855rem;
    font-weight: 400;
    color: var(--leg-sidebar-text);
    text-decoration: none;
    transition: background .14s, color .14s;
    position: relative;
    white-space: nowrap;
}

.sidebar-nav .nav-link i {
    font-size: .95rem;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    opacity: .65;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #e2eaf2;
}
.sidebar-nav .nav-link:hover i { opacity: .9; }

.sidebar-nav .nav-link.active {
    background: var(--leg-sidebar-active-bg);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid var(--leg-sidebar-active-border);
    padding-left: calc(.7rem - 3px);
}
.sidebar-nav .nav-link.active i { opacity: 1; color: #fff; }

/* Footer del sidebar: usuario */
.sidebar-user {
    border-top: 1px solid rgba(255,255,255,.06);
    padding: .75rem .8rem;
    flex-shrink: 0;
}

.sidebar-user .user-pill {
    display: flex;
    align-items: center;
    gap: .625rem;
    cursor: pointer;
    text-decoration: none;
    border-radius: .5rem;
    padding: .4rem .5rem;
    transition: background .14s;
    color: var(--leg-sidebar-text);
}

.sidebar-user .user-pill:hover { background: rgba(255,255,255,.07); }

.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--leg-blue), var(--leg-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user .user-name { font-size: .8rem; font-weight: 600; color: #d4e2f0; line-height: 1.2; }
.sidebar-user .user-role { font-size: .68rem; color: var(--leg-sidebar-section); text-transform: capitalize; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.app-topbar {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid var(--leg-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: .75rem;
    flex-shrink: 0;
}

.app-topbar .topbar-toggle {
    background: none;
    border: none;
    color: #8fa3b8;
    font-size: 1.15rem;
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: .375rem;
    line-height: 1;
    transition: background .14s, color .14s;
}

.app-topbar .topbar-toggle:hover { background: #f0f4f8; color: #374151; }

.app-topbar .breadcrumb {
    margin: 0;
    font-size: .82rem;
}

.app-topbar .breadcrumb-item a {
    color: #1a85d6;
    text-decoration: none;
    font-weight: 500;
}

.app-topbar .breadcrumb-item.active { color: #374151; font-weight: 400; }

.crm-status-badge {
    font-size: .7rem;
    font-weight: 600;
    padding: .25rem .65rem;
    border-radius: 2rem;
    letter-spacing: .03em;
}

/* ── Contenido ────────────────────────────────────────────────────────────── */
#page-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    border-radius: .75rem;
    border-color: var(--leg-border);
    box-shadow: var(--leg-card-shadow);
}

.card-header {
    font-size: .9rem;
    background: #fff;
    border-color: var(--leg-border);
}

/* KPI cards estilo CRM */
.kpi-card {
    border-radius: .75rem;
    border: 1px solid var(--leg-border);
    background: #fff;
    padding: 1.25rem;
    box-shadow: var(--leg-card-shadow);
}

.kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: #1a2b45;
}

.kpi-card .kpi-label {
    font-size: .82rem;
    color: #6b7a90;
    margin-top: .15rem;
}

/* ── Botones ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background-color: var(--leg-blue);
    border-color: var(--leg-blue);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--leg-blue-dark);
    border-color: var(--leg-blue-dark);
}
.btn-outline-primary { color: var(--leg-blue); border-color: var(--leg-blue); }
.btn-outline-primary:hover { background-color: var(--leg-blue); border-color: var(--leg-blue); }

/* ── Tablas ───────────────────────────────────────────────────────────────── */
.table th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #6b7a90;
    white-space: nowrap;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: .9rem;
    color: #1a2b45;
}

.table-hover > tbody > tr:hover > * {
    background-color: #f8fafc;
}

/* ── Alerts flash ─────────────────────────────────────────────────────────── */
.alert {
    border-radius: .65rem;
    font-size: .9rem;
    border: none;
}
.alert-success { background: #e8f8f1; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1d4ed8; }

/* ── Timeline ciclo de vida ───────────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .65rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.4rem;
    top: .35rem;
    width: .75rem;
    height: .75rem;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e2e8f0;
}

.timeline-item.success::before { background: #16a34a; box-shadow: 0 0 0 2px #bbf7d0; }
.timeline-item.warning::before { background: #d97706; box-shadow: 0 0 0 2px #fde68a; }
.timeline-item.danger::before  { background: #dc2626; box-shadow: 0 0 0 2px #fecaca; }
.timeline-item.info::before    { background: #0891b2; box-shadow: 0 0 0 2px #a5f3fc; }
.timeline-item.primary::before { background: var(--leg-blue); box-shadow: 0 0 0 2px #bfdbfe; }

/* ── Badges de estado ─────────────────────────────────────────────────────── */
.badge-estado-activo     { background-color: #16a34a; }
.badge-estado-bodega     { background-color: #64748b; }
.badge-estado-reparacion { background-color: #d97706; }
.badge-estado-baja       { background-color: #dc2626; }
.badge-estado-perdido    { background-color: #7c3aed; }

/* ── Búsqueda de clientes AJAX ────────────────────────────────────────────── */
.client-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #d1dbe8;
    border-top: none;
    border-radius: 0 0 .5rem .5rem;
    max-height: 240px;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 6px 16px rgba(0,0,0,.1);
}

.client-search-results .result-item {
    padding: .5rem .875rem;
    cursor: pointer;
    font-size: .875rem;
    color: #1a2b45;
}

.client-search-results .result-item:hover {
    background: #eff6ff;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 992px) {
    #sidebar {
        position: fixed;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #page-content-wrapper { width: 100%; }
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cursor-pointer { cursor: pointer; }
.text-leg { color: var(--leg-blue); }
.bg-leg   { background-color: var(--leg-blue); }
