/**
 * ATLAS Flask - Custom CSS Extensions
 * Medical Dashboard Additional Styles
 */

/* Foreign Terms (italic for non-Indonesian words) */
em, .foreign-term {
    font-style: italic;
    font-weight: 500;
    color: inherit;
}

/* Smooth transitions for all interactive elements */
* {
    transition-property: background-color, border-color, color, opacity, transform;
    transition-duration: 150ms;
    transition-timing-function: ease-in-out;
}

/* Custom Scrollbar (Webkit browsers) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Focus visible (accessibility) */
*:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Loading spinner (optional) */
.spinner {
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-top-color: #3B82F6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card hover effect enhancement */
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

/* Table zebra stripes (follows theme via variables) */
table tbody tr:nth-child(even) {
    background-color: var(--bg-hover);
}

/* Progress bar animation */
.progress-fill {
    transition: width 0.5s ease-in-out;
}

/* Pulse animation for status dots */
.status-dot.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Fade in animation for page load */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Mobile: Full-width cards in grid */
@media (max-width: 767px) {
    .stat-card {
        min-width: 100%;
    }
}

/* Print styles (optional) */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* Dark mode enforcement (Tailwind handles this, but as backup) */
html.dark body {
    background-color: #0F172A;
    color: #F1F5F9;
}

/* Custom badge sizes */
.badge-sm {
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
}

.badge-lg {
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
}

/* Tooltip (optional, if needed later) */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1E293B;
    color: #F1F5F9;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    border: 1px solid #334155;
}

/* Sidebar transition for mobile */
#sidebar {
    transition: transform 0.3s ease-in-out;
    background: var(--bg-sidebar-grad);
}

/* Modern elevated cards: soft shadow (both themes) */
.bg-bg-elevated {
    box-shadow: var(--shadow-card);
    border-color: var(--border-slate-700) !important;
}

/* Hover lift on main content cards (not header/modal) */
main .bg-bg-elevated:not(header):hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

/* Sticky header: subtle blur + backdrop */
header.bg-bg-elevated {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background-color: color-mix(in srgb, var(--bg-elevated) 85%, transparent) !important;
}

/* Buttons: subtle hover elevation */
button.bg-primary:hover {
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

/* Sidebar active item accent */
a.border-l-4.border-primary {
    box-shadow: inset 0 0 0 1000px rgba(59, 130, 246, 0.06);
}

/* Chart container aspect ratio */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

@media (min-width: 1024px) {
    .chart-container {
        height: 400px;
    }
}

/* Mobile: table to stacked cards (below 768px) */
@media (max-width: 767px) {
    table.data-table thead { display: none; }
    table.data-table tbody tr {
        display: block;
        padding: 1.1rem 1rem;
        margin-bottom: 1.25rem;
        border: 1px solid var(--border-slate-700);
        border-radius: 0.75rem;
        background: var(--bg-elevated);
    }
    /* Setiap cell: block, label di atas value */
    table.data-table td {
        display: block !important;
        padding: 0.55rem 0 !important;
        border: none !important;
        border-bottom: 1px solid var(--divide-slate-800) !important;
    }
    table.data-table td:last-child { border-bottom: none !important; }
    /* Label */
    table.data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: 0.62rem;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        line-height: 1.3;
        margin-bottom: 0.2rem;
        text-align: left;
    }
    /* Value: rata kiri */
    table.data-table td span,
    table.data-table td div,
    table.data-table td strong,
    table.data-table td small {
        display: block;
        text-align: left;
        font-size: 0.88rem;
        line-height: 1.5;
        color: var(--text-primary);
    }
    /* Teks mentah langsung di td (tidak dalam elemen) */
    table.data-table td {
        text-align: left;
        font-size: 0.88rem;
        line-height: 1.5;
        color: var(--text-primary);
    }
    /* Badge role / label kelas */
    table.data-table td .inline-flex {
        display: inline-flex;
        margin-left: 0;
        font-size: 0.7rem;
    }
    table.data-table td .inline-flex.gap-2 {
        font-size: 0.75rem;
    }
    /* Aksi buttons: horizontal, full-width */
    table.data-table td[data-label="Aksi"] {
        border-bottom: none !important;
        padding-top: 0.7rem !important;
    }
    table.data-table td[data-label="Aksi"] > div {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        width: 100%;
    }
    table.data-table td[data-label="Aksi"] button {
        flex: 1;
        text-align: center;
        font-size: 0.78rem;
        padding: 0.55rem 0.75rem;
    }
    table.data-table td[data-label="Aksi"] form {
        flex: 1;
    }
    table.data-table td[data-label="Aksi"] form button {
        width: 100%;
    }
    /* Edit form row */
    table.data-table tr.edit-form-row {
        display: block;
        padding: 0;
        margin: 0.75rem 0;
        border: none;
        background: transparent;
    }
    table.data-table tr.edit-form-row td {
        display: block !important;
        padding: 0.85rem !important;
        border: 1px solid var(--border-slate-700) !important;
        border-radius: 0.5rem;
        background: var(--bg-main);
    }
    table.data-table tr.edit-form-row form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }
    table.data-table tr.edit-form-row label {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-secondary);
        margin-bottom: 0.2rem;
        text-align: left;
    }
    table.data-table tr.edit-form-row input,
    table.data-table tr.edit-form-row select {
        width: 100%;
        font-size: 0.85rem;
    }
}

/* Custom select chevron (consistent spacing, theme-aware) */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.25rem !important;
    cursor: pointer;
}

select:hover {
    border-color: var(--border-strong);
}

/* Light theme: darker chevron for contrast */
:root select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'%3E%3C/polyline%3E%3C/svg%3E");
}

.dark select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'%3E%3C/polyline%3E%3C/svg%3E");
}
