/*
 * Descripción: Estilos para componentes UI reutilizables (botones, tarjetas, etc.).
 */

/* ==========================================================================
   COMPONENTS — Shared reusable UI components (used in 2+ features)
   Layer 4 of 7 — ITCSS Components
   ========================================================================== */

/* ==========================================================================
   INPUTS & FORM ELEMENTS
   ========================================================================== */

input, textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--btn-radius);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

select {
    width: 100%;
    padding: 10px 35px 10px 16px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--btn-radius);
    color: var(--text);
    font-size: 0.9rem;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23515154'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    transition: all 0.2s;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238e8e93'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
}

select:hover {
    background-color: var(--card-bg);
    border-color: var(--glass-border);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

option {
    background-color: var(--bg);
    color: var(--text);
    padding: 12px;
}

/* ==========================================================================
   UNIFIED BUTTON SYSTEM (Apple HIG)
   ========================================================================== */

/* Base Button DNA */
.btn-primary, .btn-success, .btn-error, .btn-ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 32px;
    min-height: 56px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    border: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    user-select: none;
}

/* Tactile Feedback */
.btn-primary:active, .btn-success:active, .btn-error:active, .btn-ghost:active {
    transform: scale(0.96);
    opacity: 0.85;
}

/* Solid Prominent */
.btn-primary {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.2);
    width: 100%;
}

.btn-success {
    background: linear-gradient(180deg, var(--success) 0%, #28a745 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 199, 89, 0.2);
    width: 100%;
}

.btn-error {
    background: linear-gradient(180deg, var(--error) 0%, #d70015 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.2);
    width: 100%;
}

/* Glass Platter (Ghost) */
.btn-ghost {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

[data-theme="dark"] .btn-ghost {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

[data-theme="rosa"] .btn-ghost {
    background: rgba(255, 45, 85, 0.05);
    border-color: rgba(255, 45, 85, 0.1);
    color: var(--primary);
}

.btn-ghost:hover { background: var(--card-bg); }

/* Inline / Small Variants */
.btn-primary-ghost {
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-primary-ghost:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
}

.btn-success-ghost {
    background: rgba(var(--success-rgb, 29, 157, 63), 0.05);
    border: 1px solid rgba(var(--success-rgb, 29, 157, 63), 0.3);
    color: var(--success);
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-success-ghost:hover {
    background: rgba(var(--success-rgb, 29, 157, 63), 0.1);
    border-color: var(--success);
}

.btn-error-ghost {
    background: rgba(var(--error-rgb, 215, 0, 21), 0.05);
    border: 1px solid rgba(var(--error-rgb, 215, 0, 21), 0.3);
    color: var(--error);
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-error-ghost:hover {
    background: rgba(var(--error-rgb, 215, 0, 21), 0.1);
    border-color: var(--error);
}

.btn-ghost-border {
    border: 1px solid var(--glass-border) !important;
}

[data-theme="dark"] .btn-ghost-border {
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-icon {
    width: auto;
    background: transparent;
    color: var(--text-dim);
    padding: 4px;
    font-size: 1.2rem;
}

.btn-icon:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.btn-archive-dynamic {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
}

.btn-archive-dynamic:hover {
    opacity: 1 !important;
    transform: scale(1.25);
    filter: drop-shadow(0 0 8px currentColor);
}

/* Circular Navigation Buttons */
.btn-support-apple, .btn-icono-tema {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
}

.btn-support-apple:hover, .btn-icono-tema:hover {
    transform: scale(1.1);
    background: var(--card-bg);
}

.btn-icono-tema.activo {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: var(--shadow-elevated);
    border-color: var(--primary);
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-small:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

/* Drawer button sizing */
.drawer button {
    min-height: 56px;
    padding: 0 32px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
}

.drawer button:hover {
    transform: translateY(-2px);
    opacity: 0.95;
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.2);
}

/* ==========================================================================
   NOTIFICATIONS
   ========================================================================== */

/* Apple Dynamic Island Toast Stack */
.apple-toast {
    position: relative;
    background: var(--text);
    color: var(--bg);
    padding: 14px 28px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    z-index: 10000;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.apple-toast.show { 
    opacity: 1; 
    transform: translateY(0) scale(1);
}
.apple-toast.success { background: var(--success); color: white; }
.apple-toast.error { background: var(--error); color: white; }

/* Legacy Toast (admin.js) */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    width: auto;
    max-width: 90vw;
}

@media (max-width: 768px) {
    #toast-container {
        right: 16px;
        left: 16px;
        align-items: center;
    }
}

.toast {
    padding: 12px 24px;
    border-radius: 8px;
    margin-top: 12px;
    animation: slideIn 0.3s ease-out;
}

/* ==========================================================================
   BOTTOM SHEET & DRAWER
   ========================================================================== */

/* Bottom Sheet (iOS) */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    z-index: 2000;
    padding-bottom: env(safe-area-inset-bottom);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet.open { transform: translateY(0); }

.drawer-handle {
    width: 36px;
    height: 5px;
    background: var(--glass-border);
    border-radius: 10px;
    margin: 12px auto;
}

/* Modal Overlay — z-index must stay below .drawer (1100) */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.drawer-overlay.show, body:has(.drawer.open) .drawer-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer (Side Panel) */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 500px;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 1100;
    border-radius: 0;
    border-left: 1px solid var(--glass-border);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
    background: var(--bg);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.drawer-header h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--text), var(--text-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.drawer.open { transform: translateX(0); }

.drawer-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.drawer-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawer-form label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0.5;
    margin-bottom: 8px;
}

.drawer-form input { margin-bottom: 0; }

/* ==========================================================================
   CARD
   ========================================================================== */

.card {
    padding: 24px;
    transition: transform 0.3s;
    cursor: pointer;
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color, var(--primary));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 15px var(--accent-color, rgba(138, 43, 226, 0.1));
    background: var(--card-bg);
}

.card:active { transform: scale(0.98); }

.card.highlighted {
    border-color: var(--accent-color, var(--primary)) !important;
    box-shadow: 0 0 20px var(--accent-color, var(--primary)) !important;
    transform: translateY(-4px);
    z-index: 2;
}

.card h3 { margin-bottom: 8px; }
.card p  { color: var(--text-dim); font-size: 0.9rem; }

/* ==========================================================================
   SECTION TITLE, PILL, BACK-LINK
   ========================================================================== */

.section-title {
    margin-bottom: 24px;
    opacity: 0.6;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.pill { white-space: nowrap; }

.back-link {
    cursor: pointer;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    position: relative;
    z-index: 10;
}

.back-link:hover { color: var(--text); }
.back-link span  { font-size: 1.2rem; }

/* ==========================================================================
   SWITCH / TOGGLE
   ========================================================================== */

.switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: 0.4s;
    border-radius: 22px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    top: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(16px); }

/* ==========================================================================
   IN-PLACE EDITING
   ========================================================================== */

.editable:hover::after { content: ' ✎'; opacity: 0.5; }

.editing-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid currentColor;
    color: inherit;
    width: auto;
    font-size: inherit;
    font-weight: inherit;
    padding: 0;
    margin: 0;
    outline: none;
    display: inline-block;
}

/* ==========================================================================
   THEME SELECTOR & SEGMENTED CONTROL
   ========================================================================== */

.selector-tema-horizontal, .segmented-control {
    display: flex;
    background: rgba(0,0,0,0.05);
    padding: 4px;
    border-radius: 14px;
    gap: 4px;
    width: fit-content;
}

[data-theme="dark"] .selector-tema-horizontal,
[data-theme="dark"] .segmented-control {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
}

.btn-icono-tema, .segmented-control button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.btn-icono-tema.activo, .segmented-control button.active {
    background: white;
    color: black;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="dark"] .btn-icono-tema.activo,
[data-theme="dark"] .segmented-control button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

/* ==========================================================================
   FEEDBACK SHEET (shared between student quiz and components)
   ========================================================================== */

.feedback-sheet { z-index: 3000; }

.feedback-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
}

.correct   .feedback-icon-container { color: var(--success); }
.incorrect .feedback-icon-container { color: var(--error);   }
/* Mini Theme Dropdown */
.theme-mini-menu {
    position: absolute;
    top: 50px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 3000;
    box-shadow: var(--shadow-elevated);
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-mini-menu.show {
    display: flex;
}

.theme-mini-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
    color: var(--text);
}

.theme-mini-btn:hover {
    background: rgba(0,0,0,0.05);
}

.theme-mini-btn.active {
    background: var(--primary);
    color: white;
}

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