/**
 * UMI Stock Control - Estilos con Identidad Visual UMI
 * Verde institucional + naranja de acento
 */

/* ========== Variables UMI ========== */
:root {
    /* Colores de marca UMI */
    --umi-primary:    #2EAD4A;
    --umi-dark:       #1A7A30;
    --umi-orange:     #F5821F;
    --umi-light-bg:   #F0FFF4;
    --umi-sidebar-width: 250px;
    --umi-sidebar-bg: #ffffff;

    /* Override Bootstrap 5 primary */
    --bs-primary:           #2EAD4A;
    --bs-primary-rgb:       46, 173, 74;
    --bs-link-color:        #2EAD4A;
    --bs-link-color-rgb:    46, 173, 74;
    --bs-link-hover-color:  #1A7A30;
}

/* ========== General ========== */
body {
    font-size: 15px;
    background-color: #f0f2f5;
}

.main-content {
    min-height: calc(100vh - 56px);
}

/* ========== Bootstrap Primary Overrides ========== */
.btn-primary {
    --bs-btn-bg:                #2EAD4A;
    --bs-btn-border-color:      #2EAD4A;
    --bs-btn-hover-bg:          #259040;
    --bs-btn-hover-border-color:#1A7A30;
    --bs-btn-active-bg:         #1A7A30;
    --bs-btn-active-border-color:#1A7A30;
    --bs-btn-disabled-bg:       #2EAD4A;
    --bs-btn-disabled-border-color:#2EAD4A;
    --bs-btn-focus-shadow-rgb:  46, 173, 74;
}

.btn-outline-primary {
    --bs-btn-color:             #2EAD4A;
    --bs-btn-border-color:      #2EAD4A;
    --bs-btn-hover-bg:          #2EAD4A;
    --bs-btn-hover-color:       #fff;
    --bs-btn-hover-border-color:#2EAD4A;
    --bs-btn-active-bg:         #1A7A30;
    --bs-btn-active-border-color:#1A7A30;
    --bs-btn-focus-shadow-rgb:  46, 173, 74;
}

.bg-primary {
    background-color: var(--umi-dark) !important;
}

.text-primary {
    color: var(--umi-primary) !important;
}

.border-primary {
    border-color: var(--umi-primary) !important;
}

a {
    color: var(--umi-primary);
}

a:hover {
    color: var(--umi-dark);
}

/* Input focus verde */
.form-control:focus,
.form-select:focus {
    border-color: var(--umi-primary);
    box-shadow: 0 0 0 0.25rem rgba(46, 173, 74, 0.22);
}

/* Switch verde */
.form-check-input:checked {
    background-color: var(--umi-primary);
    border-color: var(--umi-primary);
}

/* ========== Navbar ========== */
.navbar.bg-primary {
    background: linear-gradient(135deg, var(--umi-dark) 0%, var(--umi-primary) 100%) !important;
    box-shadow: 0 2px 10px rgba(26, 122, 48, 0.4);
}

/* ========== Login Page (con imagen de fondo UMI) ========== */
.login-page {
    min-height: 100vh;
    background:
        linear-gradient(rgba(26, 122, 48, 0.83), rgba(20, 90, 35, 0.90)),
        url('../img/umi-bg.jpg') center / cover no-repeat fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    max-width: 430px;
    width: 100%;
    margin: 0;
    padding: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: none;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.login-icon {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--umi-dark), var(--umi-primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    margin: 0 auto 14px;
    box-shadow: 0 8px 24px rgba(46, 173, 74, 0.45);
}

.login-brand {
    color: var(--umi-dark);
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: 4px;
    line-height: 1;
}

.login-version {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.8rem;
    margin-top: 14px;
    text-align: center;
}

.login-credits {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.75rem;
    margin-top: 8px;
    text-align: center;
    line-height: 1.4;
}

.login-credits a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.login-credits a:hover {
    color: rgba(255, 255, 255, 1);
    text-decoration: underline;
}

/* ========== Sidebar ========== */
@media (min-width: 992px) {
    .sidebar-menu {
        width: var(--umi-sidebar-width);
        min-width: var(--umi-sidebar-width);
        background: var(--umi-sidebar-bg);
        border-right: 3px solid var(--umi-primary);
        min-height: calc(100vh - 56px);
        position: sticky;
        top: 56px;
    }
}

.sidebar-nav .nav-link {
    color: #495057;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.15s;
}

.sidebar-nav .nav-link:hover {
    background-color: rgba(46, 173, 74, 0.1);
    color: var(--umi-dark);
}

.sidebar-nav .nav-link.active {
    background-color: var(--umi-primary);
    color: white;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* Header del sidebar offcanvas en mobile */
.offcanvas-header.bg-primary {
    background: linear-gradient(135deg, var(--umi-dark), var(--umi-primary)) !important;
}

/* ========== Dashboard Cards ========== */
.dashboard-card {
    transition: transform 0.15s, box-shadow 0.15s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ========== Cards generales ========== */
.card {
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* ========== Botones grandes para mobile ========== */
.btn-lg {
    padding: 12px 24px;
    font-size: 1.05rem;
    border-radius: 10px;
}

/* ========== Form controls grandes ========== */
.form-control-lg,
.form-select-lg {
    border-radius: 10px;
    padding: 10px 16px;
}

/* ========== Badges ========== */
.badge {
    font-weight: 500;
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: 6px;
}

/* ========== Tablas ========== */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6c757d;
}

.table td {
    vertical-align: middle;
}

/* ========== Chofer - Bottom Nav ========== */
.chofer-bottom-nav {
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.chofer-bottom-nav a {
    font-size: 0.75rem;
    padding: 5px 15px;
}

/* ========== Pasos de instalación PWA ========== */
.install-steps {
    list-style: none;
    padding: 0;
    counter-reset: step;
}

.install-steps li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
}

.install-steps li:last-child {
    border-bottom: none;
}

.install-steps li i {
    font-size: 1.3rem;
    min-width: 28px;
    text-align: center;
}

/* ========== Alertas ========== */
.alert {
    border-radius: 10px;
}

/* ========== Responsive ajustes ========== */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .login-page {
        padding: 15px;
        background-attachment: scroll; /* mejor performance en mobile */
    }

    h4 {
        font-size: 1.2rem;
    }

    .display-5 {
        font-size: 2rem;
    }

    .display-6 {
        font-size: 1.5rem;
    }

    .btn-lg {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .table-responsive {
        font-size: 0.85rem;
    }
}

/* ========== Print ========== */
@media print {
    .sidebar-menu,
    .navbar,
    .chofer-bottom-nav,
    .btn,
    form {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }
}

/* ========== Scrollbar personalizado ========== */
@media (min-width: 992px) {
    .sidebar-menu::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-menu::-webkit-scrollbar-thumb {
        background-color: rgba(46, 173, 74, 0.4);
        border-radius: 2px;
    }
}

/* ========== Animaciones suaves ========== */
.card,
.btn,
.nav-link {
    transition: all 0.15s ease;
}

/* ========== Form switches más grandes ========== */
.form-check-input {
    width: 3em;
    height: 1.5em;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    padding-top: 2px;
}

/* ========== Texto truncado ========== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== Loading overlay ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ========== Chatbot Widget ========== */

/* Botón flotante */
.chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--umi-dark), var(--umi-primary));
    color: white;
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(46, 173, 74, 0.45);
    z-index: 10000;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(46, 173, 74, 0.55);
}

.chatbot-fab-active {
    background: #dc3545;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
}

.chatbot-fab-active:hover {
    box-shadow: 0 6px 24px rgba(220, 53, 69, 0.5);
}

/* Popup de invitación */
.chatbot-invite {
    position: fixed;
    bottom: 90px;
    right: 24px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 14px 18px;
    max-width: 260px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    cursor: pointer;
}

.chatbot-invite-show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chatbot-invite::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.06);
}

.chatbot-invite-close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.chatbot-invite-text {
    font-size: 0.88rem;
    color: #333;
    line-height: 1.4;
}

.chatbot-invite-text strong {
    color: var(--umi-primary);
}

/* Ventana del chat */
.chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 10002;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.chatbot-window-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header del chat */
.chatbot-header {
    background: linear-gradient(135deg, var(--umi-dark), var(--umi-primary));
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chatbot-header-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.chatbot-header-status {
    font-size: 0.72rem;
    opacity: 0.8;
}

.chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.chatbot-header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* Mensajes */
.chatbot-msg {
    display: flex;
    max-width: 85%;
    animation: chatMsgIn 0.2s ease;
}

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

.chatbot-msg-user {
    align-self: flex-end;
}

.chatbot-msg-bot {
    align-self: flex-start;
}

.chatbot-msg-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
}

.chatbot-msg-user .chatbot-msg-content {
    background: var(--umi-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-msg-bot .chatbot-msg-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chatbot-msg-error .chatbot-msg-content {
    background: #fff3f3;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.chatbot-msg-content ul {
    margin: 4px 0;
    padding-left: 18px;
}

.chatbot-msg-content li {
    margin-bottom: 2px;
}

.chatbot-msg-content strong {
    font-weight: 600;
}

/* Typing indicator */
.chatbot-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #aaa;
    animation: chatTyping 1.2s infinite;
}

.chatbot-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Sugerencias */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    background: #f7f8fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.chatbot-suggestion {
    background: white;
    border: 1px solid var(--umi-primary);
    color: var(--umi-primary);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.chatbot-suggestion:hover {
    background: var(--umi-primary);
    color: white;
}

/* Input area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: white;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s;
}

.chatbot-input:focus {
    border-color: var(--umi-primary);
    box-shadow: 0 0 0 2px rgba(46, 173, 74, 0.15);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--umi-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: var(--umi-dark);
}

.chatbot-send:active {
    transform: scale(0.92);
}

/* ─── Chatbot mobile responsive ─── */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 55vh;
        height: 55vh;
        border-radius: 14px;
    }

    .chatbot-fab {
        bottom: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .chatbot-invite {
        bottom: 70px;
        right: 12px;
        max-width: 220px;
    }

    .chatbot-header {
        padding: 10px 12px;
    }

    .chatbot-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .chatbot-header-title {
        font-size: 0.88rem;
    }

    .chatbot-messages {
        padding: 10px;
        gap: 8px;
    }

    .chatbot-msg-content {
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .chatbot-suggestions {
        padding: 6px 10px;
        gap: 4px;
    }

    .chatbot-suggestion {
        padding: 4px 10px;
        font-size: 0.72rem;
    }

    .chatbot-input-area {
        padding: 8px 10px;
    }

    .chatbot-input {
        padding: 7px 12px;
        font-size: 0.82rem;
    }

    .chatbot-send {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

/* Chofer: ajustar fab para no tapar la barra inferior */
body.chofer-layout .chatbot-fab {
    bottom: 80px;
}

body.chofer-layout .chatbot-invite {
    bottom: 138px;
}

body.chofer-layout .chatbot-window {
    bottom: 138px;
    max-height: calc(100vh - 200px);
}

@media (max-width: 480px) {
    body.chofer-layout .chatbot-fab {
        bottom: 76px;
    }

    body.chofer-layout .chatbot-invite {
        bottom: 134px;
    }

    body.chofer-layout .chatbot-window {
        bottom: 134px;
        max-height: 45vh;
        height: 45vh;
    }
}

/* Print: ocultar chatbot */
@media print {
    .chatbot-fab,
    .chatbot-invite,
    .chatbot-window {
        display: none !important;
    }
}
