/* assets/css/components.css */

/* Cards */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    border: 1px solid var(--border-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.btn-primary {
    background-color: var(--color-btn-bg, var(--primary-color));
    color: var(--color-btn-text, white);
}

.btn-primary:hover {
    background-color: var(--color-btn-hover, var(--primary-hover));
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-color);
    border-color: var(--text-muted);
}

/* Icon Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.25rem;
}

.btn-icon:hover {
    background: var(--bg-color);
    color: var(--text-main);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-4);
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-main);
    background-color: var(--bg-color);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

select.form-control option,
select.form-select option {
    background-color: var(--bg-surface);
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    background-color: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 15%, transparent);
}

/* Custom File Input Modern App Style */
input[type="file"].form-control {
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    line-height: 1.5;
}

input[type="file"].form-control::file-selector-button {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: none;
    border-right: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    margin-right: 1rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-family);
    transition: background-color var(--transition-fast);
}

input[type="file"].form-control::file-selector-button:hover {
    background-color: var(--border-color);
}

/* Fix Browser Autofill Backgrounds */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-surface) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 0.875rem;
    color: var(--text-muted);
}

.input-with-icon .form-control {
    padding-left: 2.5rem;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background-color: var(--primary-bg);
    color: var(--primary-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-details h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.stat-details p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Tabs System */
.tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-4);
    gap: var(--space-4);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: var(--space-3) var(--space-2);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.tab-btn:hover {
    color: var(--primary-color);
}

[data-theme="dark"] .tab-btn:hover {
    color: var(--warning-color);
}

.tab-btn.active {
    color: var(--text-main);
    border-bottom-color: var(--primary-color);
}

[data-theme="dark"] .tab-btn.active {
    border-bottom-color: var(--warning-color);
    color: var(--text-main); /* Keep text crisp white */
}

.tab-pane {
    display: none;
    animation: fadeIn var(--transition-fast);
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Social Media Cards */
.social-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
    background: var(--bg-surface);
}

.social-card:focus-within {
    border-color: var(--primary-color);
}

.social-card i {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.social-card input {
    border: none;
    background: transparent;
    flex: 1;
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-main);
}

.social-card input:focus {
    outline: none;
}

/* Modals (Dialogs) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: flex-start; /* Changed from center to prevent top cutoff */
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow-y: auto; /* allow overlay scrolling if needed */
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: 28px;
    width: 90%;
    max-width: 500px;
    max-height: calc(100vh - var(--space-6) * 2); /* Leave space for padding */
    margin: auto; /* Centers when combined with flex-start */
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Fix for form acting as wrapper inside modal-content */
.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Evita que el header se colapse */
}

.modal-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.modal-title i {
    color: var(--text-muted);
    font-size: 1.5rem;
}

.btn-close-circular {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-close-circular:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.modal-body {
    padding: var(--space-6);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-y: auto; /* Scroll interno */
    flex: 1; /* Ocupa el espacio restante */
}

.modal-footer {
    padding: var(--space-4) var(--space-6) var(--space-6);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    background: var(--bg-surface); /* Fondo sólido */
    border-top: 1px solid var(--border-color); /* Separador sutil opcional */
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0; /* Evita que el footer se colapse */
}

/* Modales Responsivos (Móvil) */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end; /* Alinea el modal al fondo en móviles */
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 28px 28px 0 0; /* Solo bordes superiores */
        max-height: 85vh;
        transform: translateY(100%); /* Animación desde abajo */
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }
}

/* Callout / Info Box */
.callout {
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    padding: var(--space-4);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    margin: var(--space-4) 0;
    font-size: 0.875rem;
    color: var(--text-main);
}

/* Pill Buttons */
.btn-pill {
    border-radius: 9999px;
    padding: 0.5rem 1.5rem;
    font-weight: 600;
}

.btn-light {
    background: var(--bg-color);
    color: var(--text-main);
}

.btn-light:hover {
    background: var(--border-color);
}

/* Badges */
.badge-role {
    background: var(--primary-bg);
    color: var(--primary-contrast);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

[data-theme="dark"] .badge-role {
    background: var(--warning-color);
    color: var(--primary-color);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-4);
}

.table th,
.table td {
    padding: var(--space-4) var(--space-2);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    vertical-align: middle;
}

.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.table td {
    font-size: 0.875rem;
    color: var(--text-main);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive Table Cards */
@media (max-width: 768px) {
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        background-color: var(--bg-surface);
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-md);
        margin-bottom: var(--space-4);
        padding: var(--space-4);
        box-shadow: var(--shadow-sm);
    }

    .table-responsive td {
        border: none !important;
        position: relative;
        padding-left: 50% !important;
        padding-top: var(--space-2) !important;
        padding-bottom: var(--space-2) !important;
        text-align: right !important;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        min-height: 2.5rem;
    }

    .table-responsive td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
    }
}

