/* assets/css/style.css - High Contrast Design System with Mobile-First Card Partidas & Touch-Friendly Forms */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

:root {
    /* Paleta Oficial del Cliente */
    --azul-principal: #0057D9;
    --azul-oscuro: #003B8E;
    --azul-claro: #4DA3FF;
    --acento: #00C2FF;
    --gris-oscuro: #2B2D42;
    --gris-claro: #F5F7FA;
    --blanco: #FFFFFF;

    /* Configuración de Alto Contraste */
    --primary: var(--azul-principal);
    --primary-hover: var(--azul-oscuro);
    --primary-light: #EBF3FF;
    --secondary: var(--azul-claro);
    --accent: var(--acento);
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    
    --bg-main: var(--gris-claro);
    --bg-card: var(--blanco);
    --bg-card-hover: #FFFFFF;
    --bg-input: #FFFFFF;
    --border-color: #E2E8F0;
    --border-focus: var(--azul-principal);
    
    --text-main: var(--gris-oscuro);
    --text-muted: #5A5C77;
    --text-heading: #111827;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(0, 87, 217, 0.25);
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
    
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    color: var(--azul-principal);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--azul-oscuro);
}

/* Inline SVG Icon Helpers */
.svg-icon {
    width: 1.15em;
    height: 1.15em;
    fill: currentColor;
    vertical-align: -0.2em;
    display: inline-block;
    flex-shrink: 0;
}

.svg-icon-lg {
    width: 1.5em;
    height: 1.5em;
}

.svg-icon-sm {
    width: 0.95em;
    height: 0.95em;
}

/* App Header */
.app-header {
    background: var(--azul-oscuro);
    border-bottom: 3px solid var(--acento);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 59, 142, 0.2);
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Roboto', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.brand img {
    height: 42px;
    width: auto;
    object-fit: contain;
    background: #ffffff;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.brand-badge {
    background: var(--acento);
    color: var(--azul-oscuro);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Header Navigation Links */
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.nav-item {
    color: #E2E8F0;
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: var(--transition);
}

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

.nav-item.active {
    color: #ffffff;
    background: var(--azul-principal);
    box-shadow: 0 2px 6px rgba(0, 87, 217, 0.4);
    font-weight: 700;
}

/* Mobile nav menu toggle */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
}

.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    box-sizing: border-box;
}

/* Card components */
.card {
    background: var(--bg-card);
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.75rem;
    transition: var(--transition);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gris-claro);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-family: 'Roboto', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--azul-oscuro);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gris-oscuro);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="url"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1.5px solid #CBD5E1;
    border-radius: var(--radius-sm);
    color: var(--gris-oscuro);
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
    transition: var(--transition);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input::placeholder, textarea::placeholder {
    color: #94A3B8;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--azul-principal);
    box-shadow: 0 0 0 3.5px rgba(0, 87, 217, 0.18);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

/* Explicit Mobile Field Labels inside Table / Cards */
.mobile-field-label {
    display: none;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--azul-oscuro);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

/* File Upload preview */
.file-upload-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.img-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid #CBD5E1;
    background: #ffffff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.3rem;
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: var(--azul-principal);
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 87, 217, 0.3);
}

.btn-primary:hover {
    background: var(--azul-oscuro);
    box-shadow: 0 4px 10px rgba(0, 59, 142, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #F1F5F9;
    color: var(--gris-oscuro);
    border: 1.5px solid #CBD5E1;
}

.btn-secondary:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
    color: #0F172A;
}

.btn-success {
    background: #10B981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #EF4444;
    color: #ffffff;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.825rem;
    border-radius: var(--radius-sm);
}

/* High Contrast Responsive Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1.5px solid #CBD5E1;
    box-sizing: border-box;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: #ffffff;
}

th, td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #E2E8F0;
    font-size: 0.9rem;
}

th {
    background: var(--azul-oscuro);
    color: #ffffff;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.775rem;
    letter-spacing: 0.6px;
}

tr:nth-child(even) td {
    background: #F8FAFC;
}

tr:hover td {
    background: #EFF6FF;
}

/* High Contrast Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.775rem;
    font-weight: 700;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.badge-warning {
    background: #E0F2FE;
    color: #0369A1;
    border: 1px solid #BAE6FD;
}

/* Quotation Summary Totals box */
.totals-box {
    background: #F8FAFC;
    border: 2px solid #CBD5E1;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-width: 420px;
    margin-left: auto;
    width: 100%;
    box-sizing: border-box;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: var(--gris-oscuro);
    font-weight: 500;
}

.total-row.grand-total {
    border-top: 2px solid #CBD5E1;
    padding-top: 0.85rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--azul-principal);
}

/* Alert Boxes */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* Login Page centered style */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--azul-oscuro) 0%, var(--azul-principal) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header img {
    max-height: 70px;
    width: auto;
    margin-bottom: 0.75rem;
}

.auth-header h1 {
    font-family: 'Roboto', sans-serif;
    font-size: 1.65rem;
    color: var(--azul-oscuro);
    margin-top: 0.25rem;
    font-weight: 700;
}

/* Public Quote View Styling */
.public-quote-body {
    background-color: var(--gris-claro);
}

.public-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.quote-paper {
    background: #ffffff;
    color: var(--gris-oscuro);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #E2E8F0;
}

.quote-paper table th {
    background: #F1F5F9;
    color: #334155;
}

.quote-paper table td {
    color: #1E293B;
    border-bottom: 1px solid #E2E8F0;
}

/* Footer */
.app-footer {
    background: #ffffff;
    border-top: 1px solid #E2E8F0;
    padding: 1.25rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: auto;
}

/* Media Queries for Mobile Responsiveness & Touch Cards */
@media (max-width: 767px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--azul-oscuro);
        padding: 1rem;
        border-bottom: 3px solid var(--acento);
        box-shadow: var(--shadow-lg);
    }
    
    .nav-links.show {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .main-content {
        padding: 0.75rem 0.5rem;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .form-group {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    input[type="url"],
    select,
    textarea {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom on input focus */
        display: block !important;
        margin: 0 !important;
    }
    
    .totals-box {
        max-width: 100%;
    }
    
    .quote-paper {
        padding: 1.25rem;
    }

    /* Display Explicit Mobile Labels inside Cards */
    .mobile-field-label {
        display: block !important;
    }

    /* Transform Quotation Items Table into Mobile Touch Cards */
    #quoteForm .table-responsive {
        border: none;
        overflow-x: visible;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #quoteForm table, 
    #quoteForm thead, 
    #quoteForm tbody, 
    #quoteForm th, 
    #quoteForm tr {
        display: block;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #quoteForm thead {
        display: none; /* Hide standard table header row on mobile */
    }

    #quoteForm .item-row {
        background: #FFFFFF;
        border: 2px solid #CBD5E1;
        border-radius: var(--radius-md);
        padding: 1.15rem;
        margin-bottom: 1.25rem;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        position: relative;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #quoteForm .item-row td {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0;
        border: none;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #quoteForm .item-row td.item-total-cell {
        background: #F8FAFC;
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
        border: 1.5px solid #E2E8F0;
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--azul-principal);
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    #quoteForm .item-row td.item-actions-cell {
        margin-top: 0.5rem;
    }

    #quoteForm .item-row td.item-actions-cell .btn-remove-row {
        width: 100%;
        padding: 0.65rem;
        font-size: 0.9rem;
    }

    .mobile-only-text {
        display: inline !important;
    }
}

@media (min-width: 768px) {
    .mobile-only-text {
        display: none !important;
    }
}
