:root {
    --bg-color: #f0f4f8;
    --text-main: #102a43;
    --text-muted: #627d98;
    
    --primary: #3eabd6;
    --primary-hover: #2c90b8;
    
    /* Status Colors */
    --status-low: #3eabd6;
    --status-low-bg: #e0f2fe;
    
    --status-normal: #10b981;
    --status-normal-bg: #d1fae5;
    
    --status-high: #ef4444;
    --status-high-bg: #fee2e2;

    --card-bg: rgba(255, 255, 255, 0.85);
    --nav-bg: #ffffff;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* Mobile Container Simulation */
.app-container {
    width: 100%;
    max-width: 480px; /* Mobile width constraint on larger screens */
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px 16px;
    background-color: transparent;
    z-index: 10;
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.icon-btn {
    background: var(--card-bg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    font-size: 18px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.icon-btn:active {
    transform: scale(0.9);
}

/* MAIN CONTENT */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 100px; /* Padding bottom for nav */
}

/* VIEWS */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.active-view {
    display: block;
}

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

/* GLASS CARD */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255,255,255,0.5);
    margin-bottom: 24px;
}

/* DASHBOARD */
.summary-card {
    text-align: center;
    position: relative;
    overflow: hidden;
}

.summary-card h2 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.reading-display {
    margin: 16px 0 8px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.reading-display #dash-latest-value {
    font-size: 56px;
    font-weight: 700;
    line-height: 1;
}

.reading-display .unit {
    font-size: 16px;
    color: var(--text-muted);
}

.reading-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.status-low { color: var(--status-low); background: var(--status-low-bg); }
.status-normal { color: var(--status-normal); background: var(--status-normal-bg); }
.status-high { color: var(--status-high); background: var(--status-high-bg); }

.reading-time {
    font-size: 12px;
    color: var(--text-muted);
}

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

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-box i {
    font-size: 24px;
    color: var(--primary);
    opacity: 0.8;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
}

/* BUTTONS */
.primary-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius-md);
    background: var(--primary);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(62, 171, 214, 0.3);
    transition: background 0.2s, transform 0.2s;
}

.primary-btn:active {
    transform: scale(0.98);
    background: var(--primary-hover);
}

.pulse-anim {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(62, 171, 214, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(62, 171, 214, 0); }
    100% { box-shadow: 0 0 0 0 rgba(62, 171, 214, 0); }
}

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

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="number"],
.form-group input[type="datetime-local"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--border-radius-md);
    font-size: 16px;
    background: #f8fafc;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.context-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Toggle Option */
.record-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: var(--border-radius-lg);
}

.context-option input[type="radio"] {
    display: none;
}
.context-option span {
    display: inline-block;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: var(--transition-fast);
    text-align: center;
    width: 100%;
}
.context-option input[type="radio"]:checked + span {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* HISTORY */
.history-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.history-controls::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.filter-btn.active {
    background: var(--text-main);
    color: white;
}

.record-item {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.record-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.record-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.record-value-wrap {
    text-align: right;
}

.record-val {
    font-size: 20px;
    font-weight: 700;
}

.record-unit {
    font-size: 12px;
}

.record-status-indicator {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    margin-top: 4px;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* REPORTS */
.chart-container {
    width: 100%;
    position: relative;
    height: 250px;
}

.chart-container h3, .reports-summary h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.mt-4 { margin-top: 24px; }

.distribution-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.dist-row > span:first-child {
    width: 50px;
    color: var(--text-muted);
}

.dist-row > span:last-child {
    width: 40px;
    text-align: right;
    font-weight: 600;
}

.bar-bg {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    transition: width 1s ease-out;
}

.high-fill { background: var(--status-high); }
.normal-fill { background: var(--status-normal); }
.low-fill { background: var(--status-low); }


/* BOTTOM NAV */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
    border-radius: 24px 24px 0 0;
    z-index: 20;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    gap: 4px;
    cursor: pointer;
    min-width: 60px;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item-fab {
    position: relative;
    top: -20px;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(62, 171, 214, 0.4);
    cursor: pointer;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1100;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    margin: 0;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-backdrop.show .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 20px;
}

/* DATE FACADE */
.date-facade-wrapper {
    position: relative;
    width: 100%;
    height: 50px;
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
}
.date-facade-display {
    font-size: 16px;
    color: var(--text-main);
    z-index: 1;
    pointer-events: none;
    flex: 1;
}
.calendar-icon {
    color: var(--primary);
    z-index: 1;
    pointer-events: none;
}
.date-facade-input {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* RTL Support - Arabic */
html[dir="rtl"] .record-value-wrap {
    text-align: left;
}

html[dir="rtl"] .dist-row > span:last-child {
    text-align: left;
}
