/* ============================================================================
   MAIN.CSS - ESTILOS PRINCIPALES DEL CONTENIDO
   Sistema de Permisos de Salida - Sandoval Abogados
   ============================================================================ */

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background:
        radial-gradient(circle at 18% 16%, rgba(99, 102, 241, 0.2), transparent 24%),
        radial-gradient(circle at 85% 20%, rgba(16, 185, 129, 0.14), transparent 24%),
        radial-gradient(circle at 75% 80%, rgba(236, 72, 153, 0.14), transparent 26%),
        linear-gradient(180deg, #0b1120 0%, #090d1a 100%);
    color: #f8fafc;
    background-attachment: fixed;
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    margin-left: 260px;
    margin-top: 70px;
    padding: 30px;
    min-height: calc(100vh - 70px);
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   PAGE HEADER
   ============================================================================ */

.page-header {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header-left {
    flex: 1;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 8px;
}

.page-subtitle {
    color: #94a3b8;
    font-size: 14px;
}

/* ============================================================================
   STATS CARDS
   ============================================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.utoi-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mis-permisos-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
    position: relative;
    background: rgba(15, 23, 42, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    cursor: default;
}

.stat-filter-icon {
    position: absolute;
    right: 12px;
    bottom: 10px;
    font-size: 13px;
    color: #94a3b8;
    opacity: 0.9;
    pointer-events: none;
}

.stat-card[onclick] {
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-card[onclick]:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.stat-card[onclick]:active {
    transform: translateY(-1px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.green {
    background: #e8f5e9;
    color: #00853F;
}

.stat-icon.blue {
    background: #e3f2fd;
    color: #1976d2;
}

.stat-icon.orange {
    background: #fff4e5;
    color: #f59e0b;
}

.stat-icon.red {
    background: #fee;
    color: #ef4444;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 2px;
}

.stat-label {
    color: #94a3b8;
    font-size: 13px;
}

/* ============================================================================
   TOOLBAR
   ============================================================================ */

.toolbar {
    background: rgba(15, 23, 42, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(18px);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px;
    border: 1px solid #e4e6ef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #00853F;
    box-shadow: 0 0 0 3px rgba(0,133,63,0.1);
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #a1a5b7;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(99, 102, 241, 0.38);
}

.btn-secondary {
    background: #f1f1f4;
    color: #3f4254;
}

.btn-secondary:hover {
    background: #e4e6ef;
}

/* ============================================================================
   FILTER TABS
   ============================================================================ */

.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 10px 20px;
    border: 2px solid #e4e6ef;
    border-radius: 8px;
    background: white;
    color: #3f4254;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-tab:hover {
    border-color: #00853F;
    background: #f8fff8;
}

.filter-tab.active {
    background: #00853F;
    color: white;
    border-color: #00853F;
}

.filter-count {
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.filter-tab.active .filter-count {
    background: rgba(255,255,255,0.2);
}

/* ============================================================================
   PERMISSIONS TABLE
   ============================================================================ */

.permissions-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
}

.permissions-table {
    width: 100%;
    border-collapse: collapse;
}

.permissions-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e4e6ef;
}

.permissions-table th {
    padding: 15px 20px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: #3f4254;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.permissions-table td {
    padding: 15px 20px;
    border-bottom: 1px solid #e4e6ef;
    font-size: 14px;
    color: #181c32;
}

.permissions-table tbody tr {
    transition: all 0.2s;
    opacity: 1;
}

.permissions-table tbody tr[style*="display: none"] {
    opacity: 0;
}

.permissions-table tbody tr:hover {
    background: #f9fafb;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: #e8f5e9;
    color: #00853F;
}

.status-badge.returned {
    background: #e3f2fd;
    color: #1976d2;
}

.status-badge.expired {
    background: #fee;
    color: #ef4444;
}

.equipment-tag {
    display: inline-block;
    background: #f1f1f4;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin: 2px;
}

.action-btns {
    display: flex;
    gap: 5px;
}

.action-btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: #f9fafb;
    color: #3f4254;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn-icon:hover {
    background: #00853F;
    color: white;
}

.action-btn-icon.delete:hover {
    background: #ef4444;
    color: white;
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e4e6ef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #181c32;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #a1a5b7;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f1f1f4;
    color: #181c32;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e4e6ef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================================
   FORM
   ============================================================================ */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #3f4254;
    margin-bottom: 8px;
}

.form-label.required::after {
    content: '*';
    color: #ef4444;
    margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e4e6ef;
    border-radius: 8px;
    font-size: 14px;
    color: #181c32;
    transition: all 0.3s;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #00853F;
    box-shadow: 0 0 0 3px rgba(0,133,63,0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-help {
    font-size: 12px;
    color: #a1a5b7;
    margin-top: 6px;
}

#helpChevron {
    transition: transform 0.3s ease;
}

/* ============================================================================
   FLATPICKR CUSTOM STYLES
   ============================================================================ */

.flatpickr-calendar {
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border-radius: 12px;
    border: 1px solid #e4e6ef;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.flatpickr-months {
    background: #00853F;
    border-radius: 12px 12px 0 0;
    padding: 10px 0;
}

.flatpickr-month {
    color: white;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-weight: 600;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    background: rgba(255,255,255,0.3);
}

.flatpickr-current-month input.cur-year {
    color: white;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-weight: 600;
}

.flatpickr-current-month .numInputWrapper:hover {
    background: rgba(255,255,255,0.3);
}

.flatpickr-prev-month,
.flatpickr-next-month {
    fill: white;
}

.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
    fill: white;
}

.flatpickr-weekdays {
    background: #f9fafb;
    border-bottom: 1px solid #e4e6ef;
    padding: 10px 0;
}

.flatpickr-weekday {
    color: #3f4254;
    font-weight: 600;
    font-size: 12px;
}

.flatpickr-day {
    color: #181c32;
    border-radius: 8px;
    font-weight: 500;
}

.flatpickr-day:hover:not(.flatpickr-disabled):not(.selected) {
    background: #e8f5e9;
    border-color: #e8f5e9;
    color: #00853F;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: #00853F;
    border-color: #00853F;
    color: white;
    font-weight: 600;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: #006830;
    border-color: #006830;
}

.flatpickr-day.today {
    border-color: #00853F;
    background: rgba(0,133,63,0.1);
    color: #00853F;
    font-weight: 600;
}

.flatpickr-day.today:hover {
    background: #e8f5e9;
    border-color: #00853F;
}

.flatpickr-day.disabled {
    color: #e4e6ef;
}

.flatpickr-time {
    border-top: 1px solid #e4e6ef;
}

.date-input-wrapper {
    position: relative;
}

.date-input-wrapper i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #00853F;
    pointer-events: none;
    z-index: 1;
}

.form-input.date-input {
    padding-right: 40px;
    cursor: pointer;
}

.selected-equipment {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.selected-equipment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e8f5e9;
    color: #00853F;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.remove-equipment {
    background: none;
    border: none;
    color: #00853F;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.remove-equipment:hover {
    background: rgba(0,133,63,0.2);
}

/* ============================================================================
   EQUIPMENT SELECTOR
   ============================================================================ */

.equipment-selector {
    border: 1px solid #e4e6ef;
    border-radius: 8px;
    padding: 15px;
    max-height: 250px;
    overflow-y: auto;
}

.equipment-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.equipment-item:hover {
    background: #f9fafb;
}

.equipment-checkbox {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.equipment-info {
    flex: 1;
}

.equipment-name {
    font-size: 14px;
    font-weight: 600;
    color: #181c32;
}

.equipment-details {
    font-size: 12px;
    color: #a1a5b7;
    margin-top: 2px;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    color: #e4e6ef;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: #181c32;
    margin-bottom: 10px;
}

.empty-text {
    font-size: 14px;
    color: #a1a5b7;
    margin-bottom: 20px;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .utoi-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mis-permisos-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: 20px 16px 28px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .utoi-stats-grid {
        grid-template-columns: 1fr;
    }

    .mis-permisos-stats-grid {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .search-box {
        max-width: 100%;
        min-width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .page-title {
        font-size: 24px;
    }

    .toolbar-actions {
        width: 100%;
    }

    .permissions-table {
        min-width: 800px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        margin-top: 64px;
        padding: 16px 12px 24px;
        min-height: calc(100vh - 64px);
    }

    .page-title {
        font-size: 22px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 20px;
    }
}

/* Botón de cancelar (rojo) */
.action-btn-icon.btn-danger {
    background-color: #fee2e2;
    color: #dc2626;
}

.action-btn-icon.btn-danger:hover {
    background-color: #dc2626;
    color: white;
}

/* Botón danger en modal */
.btn-danger {
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-danger:hover {
    background-color: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Alert warning en modal de cancelar */
.alert-warning {
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 15px;
    border-radius: 8px;
}

.alert-warning i {
    color: #f59e0b;
    margin-right: 8px;
}

.btn-warning {
    background: #f59e0b;
    color: white;
    border: none;
}

.btn-warning:hover {
    background: #d97706;
}

/* Spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sandoval dark surface overrides */
.permissions-container,
.modal-content,
.filter-tab {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(18px);
}

.permissions-table thead,
.permissions-table tbody tr:hover,
.equipment-item:hover,
.user-info-item,
.btn-secondary,
.action-btn-icon,
.equipment-tag {
    background: rgba(255, 255, 255, 0.06);
}

.permissions-table th,
.permissions-table td,
.equipment-name,
.empty-title,
.modal-title,
.form-label,
.user-info-value {
    color: #f8fafc;
}

.permissions-table thead,
.permissions-table td,
.modal-header,
.modal-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

.search-box input,
.form-input,
.form-select,
.form-textarea,
.equipment-selector {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.search-box input:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: rgba(129, 140, 248, 0.54);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.filter-tab:hover,
.filter-tab.active,
.action-btn-icon:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(129, 140, 248, 0.28);
}

.form-help,
.empty-text,
.equipment-details,
.permissions-table th,
.search-box i {
    color: #94a3b8;
}
