/* Ernesto - Glucose & Insulin Tracker */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #f8fafc;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 20px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f472b6, #c084fc, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.subtitle {
    color: #94a3b8;
    font-size: 1rem;
}

.back-link {
    display: inline-block;
    color: #818cf8;
    text-decoration: none;
    margin-bottom: 16px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: #a5b4fc;
}

/* Main "Medir" Button */
.btn-medir {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 24px 32px;
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #ec4899, #8b5cf6, #6366f1);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    margin-bottom: 40px;
}

.btn-medir:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 50px rgba(139, 92, 246, 0.5);
}

.btn-medir:active {
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 1.8rem;
}

/* Recent Section */
.recent-section {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
}

.recent-section h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #e2e8f0;
}

/* List Container & Items */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.list-item-actions {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.action-bg {
    height: 100%;
    width: 50%;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.4rem;
    color: white;
}

.action-edit {
    background: linear-gradient(90deg, #059669 0%, #10b981 100%);
    justify-content: flex-start;
}

.action-delete {
    background: linear-gradient(270deg, #dc2626 0%, #ef4444 100%);
    justify-content: flex-end;
}

.list-item-content {
    position: relative;
    z-index: 2;
    background: #1e293b;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
}

.list-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-item-date {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.list-item-time {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.list-item-values {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: right;
}

.glucose-value {
    display: flex;
    flex-direction: column;
}

.glucose-number {
    font-size: 1.25rem;
    font-weight: 700;
}

.glucose-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: -2px;
}

.insulin-badge {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #a5b4fc;
    font-weight: 600;
    min-width: 60px;
}

.insulin-badge.empty {
    opacity: 0.3;
    background: rgba(255, 255, 255, 0.05);
    border-color: transparent;
    color: #64748b;
}

/* Glucose level colors */
.glucose-low {
    color: #f87171;
    font-weight: 600;
}

.glucose-normal {
    color: #34d399;
    font-weight: 600;
}

.glucose-high {
    color: #fbbf24;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: #64748b;
    padding: 40px 20px !important;
}

/* History Button */
.btn-history {
    display: block;
    text-align: center;
    margin-top: 24px;
    padding: 14px 24px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-history:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

.modal {
    width: 100%;
    max-width: 400px;
    background: #151e2d;
    /* Matching image background */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 32px;
    /* Large rounded corners */
    padding: 32px;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f8fafc;
}

.modal-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #f8fafc;
}

/* Form */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 12px;
    margin-left: 4px;
}

.optional {
    color: #64748b;
    font-weight: 400;
}

.input-premium {
    width: 100%;
    background: #0f172a;
    /* Darker background for inputs */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    color: #f1f5f9;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.2s;
    height: 60px;
    text-align: center;
    /* Center text for Date/Time */
    font-family: inherit;
}

#glucose.input-premium,
#insulin.input-premium {
    text-align: left;
    /* Numbers usually look better left-aligned */
    padding-left: 20px;
}

.input-premium:focus {
    outline: none;
    border-color: #6366f1;
    background: #1e293b;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-premium::placeholder {
    color: #475569;
}

/* Chrome/Safari date/time overrides */
.input-premium::-webkit-calendar-picker-indicator {
    filter: invert(0.5);
    cursor: pointer;
}

.btn-save-premium {
    width: 100%;
    padding: 18px;
    margin-top: 12px;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3);
}

.btn-save-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(124, 58, 237, 0.4);
}

.btn-save-premium:active {
    transform: scale(0.98);
}

/* History Page */
.month-section {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 24px;
}

.month-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #c084fc;
    margin-bottom: 20px;
}

.empty-state-card {
    text-align: center;
    padding: 60px 20px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
}

.empty-state-card p {
    color: #64748b;
    margin-bottom: 24px;
}

.btn-medir-small {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-weight: 500;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeIn 0.6s ease-out;
}

/* Responsive */
@media (max-width: 480px) {
    .header h1 {
        font-size: 2rem;
    }

    .btn-medir {
        padding: 20px 24px;
        font-size: 1.2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .actions-cell {
        white-space: nowrap;
    }
}

/* Action Buttons */
.actions-cell {
    white-space: nowrap;
}

.btn-action {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-action:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.btn-edit:hover {
    background: rgba(99, 102, 241, 0.2);
}

.btn-delete-action:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Confirmation Modal */
.modal-confirm {
    max-width: 360px;
    text-align: center;
}

.confirm-text {
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 24px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
}

.btn-cancel {
    flex: 1;
    padding: 14px;
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(100, 116, 139, 0.3);
    border-radius: 12px;
    color: #94a3b8;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(100, 116, 139, 0.3);
}

.btn-delete {
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}