/* --- Variables del Sistema de Diseño (Aesthetics Premium) --- */
:root {
    --bg-gradient: linear-gradient(135deg, #060d15 0%, #150610 50%, #020306 100%);
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --primary: #00a2e8;
    --primary-hover: #008ecb;
    --primary-glow: rgba(0, 162, 232, 0.4);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-glow: rgba(16, 185, 129, 0.3);
    
    --danger: #f43f5e;
    --danger-hover: #e11d48;
    --danger-glow: rgba(244, 63, 94, 0.3);
    
    --warning: #ffde17;
    --warning-glow: rgba(255, 222, 23, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --glass-blur: blur(12px);
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reseteo y Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* --- Contenedor de la Aplicación --- */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- Estilo Glassmorphism (Efecto Cristal) --- */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    padding: 24px;
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- Gestión de Pantallas (Screens) --- */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* --- Pantalla de Login --- */
#login-screen {
    display: none;
    justify-content: center;
    align-items: center;
}

#login-screen.active {
    display: flex;
}

.login-card {
    width: 100%;
    max-width: 450px;
    text-align: center;
    padding: 40px 32px;
}

.brand {
    margin-bottom: 32px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #00a2e8 0%, #e61980 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px;
    color: white;
    box-shadow: 0 8px 24px rgba(230, 25, 128, 0.45);
    animation: pulseGlow 3s infinite;
}

.brand h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(to right, #ffffff, #00a2e8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* --- Inputs y Formularios --- */
.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input, 
.input-group select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus, 
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.input-tip {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 14px var(--success-glow);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 14px var(--danger-glow);
}

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

.btn-icon-right {
    transition: transform 0.2s ease;
}

.btn-primary:hover .btn-icon-right {
    transform: translateX(4px);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: underline;
}

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

.login-footer {
    margin-top: 24px;
}

/* --- Pantalla Principal & Header --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #a7f3d0 0%, #059669 100%);
    color: #064e3b;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
}

.welcome-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.username-display {
    font-size: 20px;
    font-weight: 600;
    color: white;
}

/* --- Reloj Digital --- */
.clock-widget {
    text-align: center;
    background: rgba(15, 23, 42, 0.4);
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.digital-clock {
    font-size: 24px;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 1px;
    color: #f8fafc;
}

.clock-details {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.current-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.danger {
    background: rgba(244, 63, 94, 0.2);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* --- Barra de Resumen de Tiempo --- */
.time-summary-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.time-item {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
    justify-content: center;
}

.time-item-icon {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.time-productive .time-item-icon {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.time-out .time-item-icon {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
}

.time-idle .time-item-icon {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.15);
    border-color: rgba(148, 163, 184, 0.3);
}

.time-item-data {
    display: flex;
    flex-direction: column;
}

.time-item-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-item-value {
    font-size: 16px;
    font-weight: 700;
    color: white;
    font-family: monospace;
}

.time-productive .time-item-value {
    color: #34d399;
}

.time-out .time-item-value {
    color: #ffde17;
}

.time-divider {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
}

/* Tarjeta de tiempo fuera y otros estados */
.activity-card.card-out {
    border-color: rgba(255, 222, 23, 0.18);
}
.activity-card.card-out.active-run {
    border-color: rgba(255, 222, 23, 0.5);
    box-shadow: 0 0 15px rgba(255, 222, 23, 0.2);
}
.activity-card.card-used {
    opacity: 0.75;
    border-color: rgba(255, 255, 255, 0.05);
}

/* Badges especiales */
.special-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.badge-once {
    background: rgba(0, 162, 232, 0.15);
    color: #8ce1ff;
    border: 1px solid rgba(0, 162, 232, 0.3);
}
.badge-active-out {
    background: rgba(255, 222, 23, 0.25);
    color: #ffde17;
    border: 1px solid rgba(255, 222, 23, 0.45);
    animation: blinkDot 1.5s infinite;
}
.badge-used {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Temporizador de tarjeta */
.card-timer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.25);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.card-timer-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.card-timer-value {
    font-size: 13px;
    font-weight: 700;
    color: #00a2e8;
    font-family: monospace;
}

.activity-card.active-run .card-timer-value {
    color: #34d399;
}

.activity-card.card-out .card-timer-value {
    color: #ffde17;
}

@media (max-width: 768px) {
    .time-divider {
        display: none;
    }
}

/* --- Tablero y Grid de Actividades --- */
.section-title {
    margin-bottom: 20px;
}

.section-title h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.section-title p {
    font-size: 13px;
    color: var(--text-secondary);
}

.activities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Tarjetas de Actividades */
.activity-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 250px;
    position: relative;
    overflow: hidden;
    cursor: default;
}

.activity-card.active-run {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.activity-card.dragging {
    opacity: 0.4;
    border: 2px dashed var(--primary);
    transform: scale(0.98);
    box-shadow: none;
    z-index: 10;
}

/* Indicador de Actividad Activa */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.activity-card.active-run .indicator-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: blinkDot 1.5s infinite;
}

.activity-card.active-run .status-indicator {
    color: #34d399;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    width: 100%;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 65%;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 4px;
    transition: var(--transition);
}

.drag-handle:hover {
    color: var(--text-primary);
}

.drag-handle:active {
    cursor: grabbing;
}

.btn-delete-card {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-delete-card:hover {
    color: var(--danger);
    background: rgba(244, 63, 94, 0.12);
}

.card-header h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Contadores Rápidos */
.card-stats {
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.3);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
}

.stat-item strong {
    color: white;
}

/* Botones de Entrada / Salida */
.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.card-actions .btn {
    font-size: 13px;
    padding: 10px;
}

/* Historial dentro de la tarjeta */
.card-history {
    flex-grow: 1;
    font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
    max-height: 90px;
    overflow-y: auto;
}

.card-history-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-size: 11px;
    text-transform: uppercase;
}

.history-item {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    padding: 2px 0;
}

.history-item.entrada-row {
    color: #a7f3d0;
}

.history-item.salida-row {
    color: #fca5a5;
}

.card-history-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Tarjeta Botón de Añadir */
.add-activity-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    min-height: 250px;
}

.add-activity-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--primary);
    color: var(--primary);
}

.add-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    transition: var(--transition);
}

.add-activity-card:hover .add-icon-wrapper {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- Modales --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.btn-close-modal:hover {
    color: white;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
    margin-top: 20px;
}

/* --- Panel de Administración --- */
.admin-card {
    width: 100%;
    max-width: 700px;
    animation: slideUp 0.3s ease;
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
}

.admin-view {
    display: none;
}

.admin-view.active {
    display: block;
}

.admin-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.btn-fetch {
    margin-bottom: 20px; /* alinear con inputs */
}

.log-output-container {
    margin-bottom: 20px;
}

.log-output-container label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.log-textarea {
    width: 100%;
    height: 300px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    color: #38bdf8; /* Azul estilo consola */
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.admin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- Animaciones --- */
@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

@keyframes blinkDot {
    0% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 0.3;
    }
}

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

/* --- Scrollbar Custom --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .user-info {
        flex-direction: column;
        text-align: center;
    }
    
    .admin-controls {
        grid-template-columns: 1fr;
    }
    
    .btn-fetch {
        margin-bottom: 0;
    }
    
    .admin-actions {
        flex-direction: column;
    }
    
    .admin-actions .btn {
        width: 100%;
    }
}
