/* ================================================================
   STC ALLCONTROL — MODULES BASE CSS
   Estilos compartidos para todos los módulos internos
   (facturacion, pagosfijos, otrosgastos, calendario, manuales)
   ================================================================ */

/* ======================== VARIABLES ======================== */
:root {
    --mod-blue: #3b82f6;
    --mod-cyan: #06b6d4;
    --mod-emerald: #10b981;
    --mod-amber: #f59e0b;
    --mod-red: #ef4444;
    --mod-violet: #8b5cf6;

    --mod-bg: #0f172a;
    --mod-surface: rgba(15, 23, 42, 0.95);
    --mod-card: rgba(30, 41, 59, 0.8);
    --mod-card-hover: rgba(30, 41, 59, 0.95);
    --mod-input: rgba(15, 23, 42, 0.7);
    --mod-text: #e2e8f0;
    --mod-text-sec: #94a3b8;
    --mod-text-dim: #64748b;
    --mod-border: rgba(148, 163, 184, 0.12);
    --mod-radius: 10px;
    --mod-radius-sm: 6px;
    --mod-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================== RESET ======================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--mod-bg);
    color: var(--mod-text);
    line-height: 1.5;
    min-height: 100vh;
}

a { text-decoration: none; color: var(--mod-blue); }
a:hover { text-decoration: underline; }

/* ======================== LAYOUT ======================== */
.mod-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.mod-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--mod-surface);
    border: 1px solid var(--mod-border);
    border-radius: var(--mod-radius);
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}

.mod-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mod-header-title i {
    font-size: 1.3rem;
    color: var(--mod-blue);
}

.mod-header-title h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--mod-text);
}

.mod-header-title small {
    font-size: 0.7rem;
    color: var(--mod-text-dim);
    font-weight: 400;
    margin-left: 8px;
}

.mod-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ======================== CARDS ======================== */
.mod-card {
    background: var(--mod-card);
    border: 1px solid var(--mod-border);
    border-radius: var(--mod-radius);
    padding: 16px;
    transition: var(--mod-transition);
}

.mod-card:hover {
    border-color: rgba(59, 130, 246, 0.2);
}

.mod-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mod-text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mod-card-title i {
    color: var(--mod-blue);
}

/* ======================== STATS ROW ======================== */
.mod-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.mod-stat {
    background: var(--mod-card);
    border: 1px solid var(--mod-border);
    border-radius: var(--mod-radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mod-stat-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
}

.mod-stat-info { overflow: hidden; }

.mod-stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--mod-text);
    font-variant-numeric: tabular-nums;
}

.mod-stat-label {
    font-size: 0.68rem;
    color: var(--mod-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ======================== TABLES (Excel-style) ======================== */
.mod-table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(148,163,184,0.2);
    border-radius: 6px;
}

.mod-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.mod-table thead th {
    padding: 8px 12px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #cbd5e1;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148,163,184,0.15);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.mod-table thead th:hover {
    background: rgba(51, 65, 85, 0.95);
    color: #f1f5f9;
}

.mod-table thead th .sort-icon {
    margin-left: 4px;
    font-size: 0.6rem;
    opacity: 0.4;
}

.mod-table thead th .sort-icon.active {
    opacity: 1;
    color: var(--mod-emerald);
}

.mod-table tbody tr {
    transition: background 0.1s;
}

.mod-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.3);
}

.mod-table tbody tr:nth-child(odd) {
    background: rgba(30, 41, 59, 0.2);
}

.mod-table tbody tr:hover {
    background: rgba(51, 65, 85, 0.5);
}

.mod-table tbody td {
    padding: 7px 12px;
    color: var(--mod-text-sec);
    vertical-align: middle;
    border: 1px solid rgba(148,163,184,0.08);
    font-size: 0.78rem;
}

.mod-table tbody td:first-child {
    color: var(--mod-text);
    font-weight: 500;
}

.mod-table tfoot td {
    padding: 10px 12px;
    font-weight: 700;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148,163,184,0.15);
    color: var(--mod-text);
}

/* ======================== BUTTONS ======================== */
.mod-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--mod-border);
    border-radius: var(--mod-radius-sm);
    background: var(--mod-card);
    color: var(--mod-text-sec);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--mod-transition);
    white-space: nowrap;
    font-family: inherit;
}

.mod-btn:hover {
    background: var(--mod-card-hover);
    color: var(--mod-text);
    border-color: rgba(59, 130, 246, 0.3);
}

.mod-btn-primary {
    background: var(--mod-blue);
    color: #fff;
    border-color: var(--mod-blue);
}

.mod-btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.mod-btn-success {
    background: var(--mod-emerald);
    color: #fff;
    border-color: var(--mod-emerald);
}

.mod-btn-success:hover {
    background: #059669;
    border-color: #059669;
}

.mod-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

.mod-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.mod-btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem;
}

.mod-btn i { font-size: 0.8rem; }

/* ======================== FORMS ======================== */
.mod-input,
.mod-select,
.mod-textarea {
    width: 100%;
    padding: 9px 14px;
    background: var(--mod-input);
    border: 1px solid var(--mod-border);
    border-radius: var(--mod-radius-sm);
    color: var(--mod-text);
    font-size: 0.82rem;
    font-family: inherit;
    transition: var(--mod-transition);
    outline: none;
}

.mod-input:focus,
.mod-select:focus,
.mod-textarea:focus {
    border-color: var(--mod-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.mod-input::placeholder { color: var(--mod-text-dim); }

.mod-select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.mod-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--mod-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.mod-form-group {
    margin-bottom: 14px;
}

.mod-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

/* ======================== TABS (inside modules) ======================== */
.mod-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--mod-border);
    margin-bottom: 16px;
    overflow-x: auto;
    flex-shrink: 0;
    min-height: 40px;
}

.mod-tab {
    padding: 10px 18px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--mod-text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--mod-transition);
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.mod-tab:hover {
    color: var(--mod-text-sec);
    background: rgba(148, 163, 184, 0.05);
}

.mod-tab.active {
    color: var(--mod-blue);
    border-bottom-color: var(--mod-blue);
    font-weight: 700;
}

/* ======================== BADGES ======================== */
.mod-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.mod-badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.mod-badge-green { background: rgba(16,185,129,0.15); color: #34d399; }
.mod-badge-amber { background: rgba(245,158,11,0.15); color: #fbbf24; }
.mod-badge-red { background: rgba(239,68,68,0.15); color: #f87171; }
.mod-badge-violet { background: rgba(139,92,246,0.15); color: #a78bfa; }

/* ======================== MODALS ======================== */
.mod-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.mod-modal-overlay.active {
    display: flex;
}

.mod-modal {
    background: var(--mod-surface);
    border: 1px solid var(--mod-border);
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.mod-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mod-border);
}

.mod-modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mod-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--mod-text-dim);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--mod-transition);
}

.mod-modal-close:hover {
    background: var(--mod-red);
    color: #fff;
}

.mod-modal-body {
    padding: 20px;
}

.mod-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--mod-border);
}

/* ======================== TOAST / NOTIFICATIONS ======================== */
.mod-toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mod-toast {
    padding: 12px 18px;
    border-radius: var(--mod-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
}

.mod-toast-success { background: var(--mod-emerald); }
.mod-toast-error { background: var(--mod-red); }
.mod-toast-info { background: var(--mod-blue); }
.mod-toast-warning { background: var(--mod-amber); color: #0f172a; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ======================== LOADING ======================== */
.mod-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--mod-text-dim);
}

.mod-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--mod-border);
    border-top-color: var(--mod-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ======================== EMPTY STATE ======================== */
.mod-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--mod-text-dim);
}

.mod-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.mod-empty p {
    font-size: 0.9rem;
}

/* ======================== MONEY ======================== */
.mod-money {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mod-money-positive { color: var(--mod-emerald); }
.mod-money-negative { color: var(--mod-red); }

/* ======================== SCROLLBAR ======================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mod-text-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--mod-text-sec); }

/* ======================== RESPONSIVE ======================== */
@media (max-width: 768px) {
    .mod-container { padding: 12px; }
    .mod-header { padding: 12px 14px; }
    .mod-header-title h1 { font-size: 0.95rem; }
    .mod-stats { grid-template-columns: repeat(2, 1fr); }
    .mod-form-row { grid-template-columns: 1fr; }
    .mod-table { font-size: 0.75rem; }
    .mod-table thead th,
    .mod-table tbody td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .mod-stats { grid-template-columns: 1fr; }
    .mod-modal { max-width: 100%; }
}
