/**
 * SISTEMA RESPONSIVE GLOBAL
 * Archivo centralizado para responsive design
 * Aplicable a TODOS los módulos de la aplicación
 * 
 * Breakpoints:
 * - Mobile: <= 768px
 * - Tablet: 769px - 991px
 * - Desktop: >= 992px
 */

/* ============================
   RESET Y BASE
   ============================ */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
}

/* ============================
   SISTEMA DE GRID
   ============================ */
.container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.col,
.col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

/* Desktop Grid */
@media (min-width: 992px) {
    .col { flex: 1 0 0%; }
    .col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-3 { flex: 0 0 25%; max-width: 25%; }
    .col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-6 { flex: 0 0 50%; max-width: 50%; }
    .col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-9 { flex: 0 0 75%; max-width: 75%; }
    .col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ============================
   CARDS
   ============================ */
.card {
    background: #fff;
    border: 1px solid #d4d4d5;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card-header {
    background: #f9fafb;
    border-bottom: 1px solid #d4d4d5;
    padding: 0.75rem 1rem;
    font-weight: bold;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    background: #f9fafb;
    border-top: 1px solid #d4d4d5;
    padding: 0.75rem 1rem;
}

/* ============================
   FORMULARIOS
   ============================ */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -5px;
    margin-left: -5px;
}

.form-row > .form-group,
.form-row > .col,
.form-row > [class*="col-"] {
    padding-right: 5px;
    padding-left: 5px;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid #d4d4d5;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #2185d0;
    outline: 0;
    box-shadow: 0 0 0 2px rgba(33, 133, 208, 0.2);
}

/* ============================
   BOTONES
   ============================ */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.15s ease-in-out;
    min-height: 44px; /* Tamaño táctil mínimo */
    text-decoration: none;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    color: #fff;
    background-color: #2185d0;
    border-color: #2185d0;
}

.btn-success {
    color: #fff;
    background-color: #21ba45;
    border-color: #21ba45;
}

.btn-danger {
    color: #fff;
    background-color: #db2828;
    border-color: #db2828;
}

.btn-warning {
    color: #fff;
    background-color: #f2711c;
    border-color: #f2711c;
}

.btn-secondary {
    color: #fff;
    background-color: #767676;
    border-color: #767676;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============================
   TABLAS RESPONSIVE
   ============================ */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    margin-bottom: 0;
}

/* Ocultar tablas en mobile, mostrar versión card */
@media (max-width: 768px) {
    .table-desktop-only {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .table-mobile-only {
        display: none !important;
    }
}

/* ============================
   VISIBILIDAD POR DISPOSITIVO
   ============================ */
/* Mobile Only */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
    
    .mobile-inline {
        display: inline !important;
    }
    
    .mobile-flex {
        display: flex !important;
    }
}

/* Desktop Only */
.desktop-only {
    display: none !important;
}

@media (min-width: 769px) {
    .desktop-only {
        display: block !important;
    }
    
    .desktop-inline {
        display: inline !important;
    }
    
    .desktop-flex {
        display: flex !important;
    }
}

/* Tablet Only */
@media (min-width: 769px) and (max-width: 991px) {
    .tablet-only {
        display: block !important;
    }
}

/* ============================
   MOBILE RESPONSIVE (<= 768px)
   ============================ */
@media (max-width: 768px) {
    /* Contenedor principal */
    body {
        padding-top: 60px; /* Espacio para menú fijo */
    }
    
    /* Solo aplicar a contenedores con clase específica, no todos los ui.container */
    .container-fluid {
        width: 100vw !important;
        max-width: 100vw !important;
        padding: 0.5rem !important;
        margin: 0 !important;
    }
    
    /* Formularios en mobile */
    .form-group,
    .field {
        margin-bottom: 1rem;
    }
    
    /* Solo inputs en formularios, no en menús */
    .form-control,
    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group input[type="tel"],
    .form-group input[type="date"],
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.75rem !important;
        font-size: 16px !important; /* Evitar zoom en iOS */
        min-height: 44px !important; /* Táctil */
    }
    
    /* Labels arriba en mobile - solo en formularios */
    .form-label,
    .form-group label,
    .field > label {
        display: block !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        font-weight: 600 !important;
    }
    
    /* Botones SOLO con clase .btn, NO todos los button ni .ui.button */
    .btn {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
    }
    
    /* Botones con clase .btn-block específicamente */
    .btn-block {
        display: block !important;
        width: 100% !important;
    }
    
    /* Cards en mobile */
    .card {
        width: 100vw !important;
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }
    
    /* Filas de formulario en columna */
    .form-row {
        flex-direction: column;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    /* Ocultar scroll horizontal solo en body/html */
    body,
    html {
        overflow-x: hidden !important;
    }
    
    /* Espaciado táctil SOLO para botones con clase .btn */
    .btn,
    .clickable {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Tablas como cards en mobile */
    .mobile-card-list {
        width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .mobile-card-item {
        width: 100vw !important;
        margin: 0 0 1rem 0 !important;
        padding: 1rem !important;
        border-bottom: 1px solid #ddd !important;
        background: #fff !important;
    }
    
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .mobile-card-row:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .mobile-label {
        font-weight: 600;
        color: #666;
        flex: 0 0 40%;
        font-size: 0.9rem;
    }
    
    .mobile-value {
        flex: 1;
        text-align: right;
        font-size: 1rem;
    }
}

/* ============================
   TABLET (769px - 991px)
   ============================ */
@media (min-width: 769px) and (max-width: 991px) {
    .container-fluid {
        max-width: 720px;
    }
    
    /* Ajustar grid para tablet */
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ============================
   DESKTOP (>= 992px)
   ============================ */
@media (min-width: 992px) {
    .container-fluid {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container-fluid {
        max-width: 1140px;
    }
}

/* ============================
   UTILIDADES
   ============================ */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }

/* ============================
   COMPATIBILIDAD SEMANTIC UI
   ============================ */
@media (max-width: 768px) {
    /* Ajustar segmentos */
    .ui.segment {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Ajustar modales */
    .ui.modal {
        width: 95vw !important;
        margin: 0 auto !important;
    }
}

