/* ==============================================
   OPTIMIZED CSS - UNIFIED RESPONSIVE SYSTEM
   ============================================== */

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f7fc;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Layout Structure */
.content {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.filter {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin: 1rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* ==============================================
   NAVIGATION SYSTEM
   ============================================== */

.navtop {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navtop h1, .navtop h3 {
    color: white;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.navtop h3 {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.navtop h1 {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
}

/* Responsive Menu */
.respmenu {
    position: relative;
    background: #34495f;
}

.respmenu input[type="checkbox"] {
    display: none;
}

.respmenu .fas {
    display: none;
    cursor: pointer;
    padding: 1rem;
    color: white;
    font-size: 1.5rem;
    position: absolute;
    top: 0;
    right: 1rem;
    z-index: 1001;
}

.respmenu .fa-bars { display: block; }
.respmenu .fa-times { display: none; }

.respmenu input:checked ~ .fa-bars { display: none; }
.respmenu input:checked ~ .fa-times { display: block; }

.respmenu nav {
    background: rgba(52, 73, 94, 0.95);
}

.respmenu ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem;
    gap: 0.5rem;
}

.respmenu li {
    margin: 0.25rem;
}

.respmenu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    white-space: nowrap;
    border: 1px solid transparent;
}

.respmenu a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.respmenu a i {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
}

/* ==============================================
   FORM COMPONENTS
   ============================================== */

/* Form Containers */
.form, .main-content, .login-content {
    padding: 2rem;
}

.determinante-form, .login form {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Form Groups & Labels */
.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group label,
.determinante-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1rem;
}

.determinante-form label {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.required {
    color: red;
    font-weight: bold;
}

/* Input Controls */
.form-control,
.form input[type="text"],
.form input[type="tel"],
.form input[type="date"],
.form select {
    width: 100%;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    color: #333;
}

.form-control {
    max-width: 500px;
    height: 45px;
}

.form-control:focus,
.form input:focus,
.form select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Select Styling */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Input Groups with Icons */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group .form-control {
    padding-left: 3rem;
    margin-bottom: 0;
}

.input-group .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 1.1rem;
    transition: color 0.3s ease;
    z-index: 1;
}

.input-group .form-control:focus + .input-icon {
    color: #667eea;
}

/* Form Grid System */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.form-row.two-columns {
    grid-template-columns: 1fr 1fr;
}

.form-row.three-columns {
    grid-template-columns: 1fr 1fr 1fr;
}

/* ==============================================
   BUTTONS
   ============================================== */

.btn-primary, .button {
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.button {
    background: linear-gradient(135deg, #750505db, #5a0404);
    box-shadow: 0 4px 15px rgba(117, 5, 5, 0.3);
    width: 100%;
    max-width: 300px;
    margin: 2rem auto 0;
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(117, 5, 5, 0.4);
    background: linear-gradient(135deg, #5a0404, #450303);
}

.btn-primary:active, .button:active {
    transform: translateY(0);
}

/* Button Loading State */
.btn-primary.loading, .button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-primary.loading::after, .button.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid transparent;
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==============================================
   LOGIN SPECIFIC STYLES
   ============================================== */

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    animation: slideDown 0.6s ease;
}

.login:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

.login-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo-container {
    margin-bottom: 2rem;
    position: relative;
}

.logo-container img {
    max-width: 120px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

.logo-container img:hover {
    transform: scale(1.05);
}

.logo-placeholder {
    width: 120px;
    height: 60px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin: 0 auto;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* ==============================================
   TABLE STYLES
   ============================================== */

.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.default {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.default th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 1rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 3px solid #667eea;
}

.default td {
    padding: 1rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.default tr:nth-child(even) {
    background: #f8f9fa;
}

.default tr:hover {
    background: #e3f2fd;
}

.default td:first-child {
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: #2c3e50;
}

.default th:first-child,
.default td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background: rgba(255, 255, 255);
    border-right: 2px solid rgba(20,50,90,.5);
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    min-width: 100px;
    max-width: 150px;
}

table.default th:first-child {
    background: rgba(0,102,255);
    z-index: 11;
}

/* ==============================================
   VALIDATION & ERROR STATES
   ============================================== */

/* Error States */
.form-control.error,
.form input.error,
.input-group.error .form-control {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.input-group.error .form-control {
    animation: shake 0.5s ease-in-out;
}

/* Success States */
.input-group.success .form-control,
.form-group.valid .form-control {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.form-group.invalid .form-control {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Read-only fields */
input[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

#ErrorClabe {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
    color: #dc3545;
}

/* ==============================================
   UTILITY CLASSES
   ============================================== */

.date-header {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    margin-bottom: 2rem;
    color: #2c3e50;
    font-weight: 600;
    text-align: center;
}

.nomenclatura {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.8;
    text-align: left;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.option-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.option-input:hover {
    transform: scale(1.1);
}

.option-input:checked {
    transform: scale(1.2);
}

.footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
    font-size: 0.9rem;
}

/* ==============================================
   SCROLLBAR STYLING
   ============================================== */

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* ==============================================
   ANIMATIONS
   ============================================== */

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.respmenu input:checked ~ nav,
.form,
.login {
    animation: slideDown 0.3s ease;
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */

/* Tablets (1024px) */
@media (max-width: 1024px) {
    .filter, .login {
        margin: 0.5rem;
        border-radius: 10px;
    }

    .navtop, .login-header {
        padding: 1rem;
    }

    .form, .main-content, .login-content {
        padding: 1.5rem;
    }

    .determinante-form, .login form {
        padding: 1.5rem;
    }

    .default th, .default td {
        padding: 0.8rem 0.4rem;
        font-size: 0.9rem;
    }

    .form-row.three-columns {
        grid-template-columns: 1fr 1fr;
    }

    .login {
        max-width: 380px;
    }
}

/* Mobile (768px) */
@media (max-width: 768px) {
    body.login-page {
        padding: 0.5rem;
    }

    .filter, .login {
        margin: 0;
        border-radius: 0;
        max-width: 100%;
    }

    .navtop, .login-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
    }

    .respmenu .fas {
        display: block;
    }

    .respmenu nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        z-index: 1000;
    }

    .respmenu input:checked ~ nav {
        max-height: 100vh;
    }

    .respmenu ul {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    .respmenu li {
        margin: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .respmenu a {
        padding: 1rem;
        border-radius: 0;
        background: transparent;
        justify-content: flex-start;
    }

    .form, .main-content, .login-content {
        padding: 1rem;
    }

    .determinante-form, .login form {
        padding: 1rem;
        border-radius: 8px;
    }

    .form-control {
        max-width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form input, .form select {
        font-size: 16px;
    }

    .form-row.two-columns,
    .form-row.three-columns {
        grid-template-columns: 1fr;
    }

    .nomenclatura {
        padding: 1rem;
        font-size: 0.85rem;
    }

    .default {
        min-width: 600px;
    }

    .default th, .default td {
        padding: 0.6rem 0.3rem;
        font-size: 0.8rem;
    }

    .option-input {
        width: 16px;
        height: 16px;
    }

    .logo-container {
        margin-bottom: 1.5rem;
    }

    .logo-placeholder {
        max-width: 100px;
        height: 50px;
        font-size: 12px;
    }

    .input-group .form-control {
        font-size: 0.9rem;
        padding: 0.6rem 1rem 0.6rem 2.8rem;
    }

    .btn-primary, .button {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Small Mobile (480px) */
@media (max-width: 480px) {
    .navtop h3, .login h1 {
        font-size: 1rem;
        line-height: 1.3;
    }

    .navtop, .login-header {
        padding: 0.8rem;
    }

    .form, .main-content, .login-content {
        padding: 0.5rem;
    }

    .determinante-form, .login form {
        padding: 0.8rem;
    }

    .form-group {
    }

    .nomenclatura {
        padding: 0.8rem;
        font-size: 0.8rem;
    }

    .default {
        min-width: 500px;
    }

    .default th, .default td {
        padding: 0.5rem 0.2rem;
        font-size: 0.75rem;
    }

    .logo-placeholder {
        width: 80px;
        height: 40px;
        font-size: 11px;
    }

    .input-group .form-control {
        height: 40px;
        padding: 0.5rem 0.8rem 0.5rem 2.5rem;
        font-size: 0.85rem;
    }

    .input-group .input-icon {
        left: 0.8rem;
        font-size: 1rem;
    }

    .form-control, .form input, .form select {
        padding: 0.6rem 0.8rem;
        font-size: 16px;
    }

    .btn-primary, .button {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }

    .button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        margin-top: 1.5rem;
    }
}

/* ==============================================
   ACCESSIBILITY & PREFERENCES
   ============================================== */

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Indicators */
.form-control:focus-visible,
.form input:focus-visible,
.form select:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.btn-primary:focus-visible {
    outline: 2px solid #764ba2;
    outline-offset: 2px;
}

.button:focus-visible {
    outline: 2px solid #750505db;
    outline-offset: 2px;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .respmenu a:hover,
    .btn-primary:hover,
    .button:hover {
        transform: none;
        box-shadow: none;
    }
}