/* ============================================================
   IoT Pesantren - Appzia-Inspired Stylesheet
   Gaya mengikuti Appzia Flutter Admin Panel Template
   Font: Poppins | Primary: #009678 (Teal) | Sidebar: #2a323c
   ============================================================ */

/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

/* ===== CSS Variables (Appzia Color Palette) ===== */
:root {
    /* Primary & Accent */
    --primary: #009678;
    --primary-dark: #007d64;
    --primary-light: #e0f5f0;
    --primary-rgb: 0, 150, 120;
    --content-primary: #04a2b3;

    /* Semantic Colors */
    --secondary: #74788d;
    --success: #66d203;
    --success-dark: #4da302;
    --success-light: #eefbd3;
    --danger: #e66060;
    --danger-dark: #c94444;
    --danger-light: #fce8e8;
    --warning: #ffb600;
    --warning-dark: #d49900;
    --warning-light: #fff6d9;
    --info: #00a4fe;
    --info-dark: #0082cc;
    --info-light: #ddf2ff;

    /* Backgrounds */
    --bg: #f1f5f7;
    --bg-content: #fafbfe;
    --bg-white: #ffffff;

    /* Text */
    --text: #313a46;
    --text-secondary: #6c757d;
    --text-muted: #98a6ad;

    /* Borders & Dividers */
    --border: #e8ecf1;
    --divider: #e8e8e8;

    /* Sidebar (Dark by default like Appzia) */
    --sidebar-bg: #2a323c;
    --sidebar-text: #dcdcdc;
    --sidebar-label: #879baf;
    --sidebar-active-bg: #363c44;
    --sidebar-width: 255px;

    /* TopBar */
    --topbar-bg: rgba(255, 255, 255, 0.965);
    --topbar-height: 69px;

    /* Shadows (very subtle like Appzia) */
    --shadow: 0 1px 4px rgba(154, 161, 171, 0.15);
    --shadow-md: 0 2px 8px rgba(154, 161, 171, 0.2);
    --shadow-lg: 0 4px 16px rgba(154, 161, 171, 0.25);
    --shadow-card: 0 0.5px 3px rgba(154, 161, 171, 0.15);

    /* Layout */
    --radius: 4px;
    --radius-lg: 8px;
    --transition: all 0.25s ease;
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Decorative Color Groups (Appzia style) */
    --pink-bg: #FFC2D9; --pink-fg: #F5005E;
    --violet-bg: #D0BADE; --violet-fg: #4E2E60;
    --blue-bg: #ADD8FF; --blue-fg: #004A8F;
    --green-bg: #AFE9DA; --green-fg: #165041;
    --orange-bg: #FFCEC2; --orange-fg: #FF3B0A;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 14px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-weight: 400;
    letter-spacing: 0.25px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85em;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--danger);
}

/* ===== Typography (Poppins, Appzia Scale) ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    letter-spacing: -0.15px;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

.section-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text);
    position: relative;
    padding-left: 14px;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 3px;
    width: 3px;
    background: var(--primary);
    border-radius: 2px;
}

/* ===== Container ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Public Navbar (Appzia TopBar-inspired, white) ===== */
.navbar {
    background: var(--topbar-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0 32px;
    height: var(--topbar-height);
    backdrop-filter: blur(10px);
}

.navbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 2px;
}

.navbar-brand span {
    color: var(--primary);
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 2px;
}

.navbar-nav a {
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.93rem;
    transition: var(--transition);
}

.navbar-nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.navbar-nav a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
    border-radius: var(--radius);
}

.navbar-toggle:hover {
    background: var(--bg);
}

/* ===== Hero Section (Appzia-inspired, solid teal) ===== */
.hero-section {
    background: var(--primary);
    color: white;
    padding: 72px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
}

.hero-section h1 {
    font-size: 2.2rem;
    color: white;
    margin-bottom: 12px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.hero-section p {
    font-size: 1.05rem;
    opacity: 0.85;
    max-width: 600px;
    margin: 0 auto 28px;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.hero-btn {
    display: inline-block;
    background: white;
    color: var(--primary);
    padding: 12px 32px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.hero-btn:hover {
    background: #f0f0f0;
    color: var(--primary-dark);
    transform: translateY(-1px);
}

/* ===== Cards (Appzia: white, 4px radius, very subtle shadow, 1px border) ===== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--divider);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.card-header.solar { border-bottom-color: var(--warning); }
.card-header.dryer { border-bottom-color: var(--danger); }
.card-header.cattle { border-bottom-color: var(--primary); }
.card-header.permaculture { border-bottom-color: var(--content-primary); }

.card-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin: 8px 0;
}

.card-unit {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.card-footer {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 32px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.overview-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 28px;
    text-align: center;
    transition: var(--transition);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    cursor: pointer;
}

.overview-card:nth-child(1) { border-left-color: var(--warning); }
.overview-card:nth-child(2) { border-left-color: var(--danger); }
.overview-card:nth-child(3) { border-left-color: var(--success); }
.overview-card:nth-child(4) { border-left-color: var(--content-primary); }

.overview-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.overview-card h3 {
    font-size: 1rem;
    margin-bottom: 6px;
    font-weight: 600;
}

.overview-card .overview-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.overview-card .overview-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===== Status Indicator ===== */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.status-normal {
    background: var(--success);
    box-shadow: 0 0 6px rgba(102, 210, 3, 0.4);
    animation: pulse 2s infinite;
}

.status-warning {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(255, 182, 0, 0.4);
    animation: pulse 1.5s infinite;
}

.status-danger {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(230, 96, 96, 0.4);
    animation: pulse 1s infinite;
}

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

/* ===== Chart Container ===== */
.chart-container {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.chart-container h3 {
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

/* ===== Tables (Appzia style: clean, no dark header) ===== */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-white);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.data-table th {
    background: var(--bg);
    color: var(--text);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: rgba(0, 150, 120, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Buttons (Appzia: 4px radius, subtle elevation) ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.5;
    letter-spacing: 0.1px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

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

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

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-dark);
    color: white;
}

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

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

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: var(--info-dark);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn[disabled],
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== Forms (Appzia: subtle borders, 4px radius, focused with primary) ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.93rem;
    font-family: var(--font);
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.12);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
    appearance: auto;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border-left-color: var(--success);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
    border-left-color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border-left-color: var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
    border-left-color: var(--info);
}

/* ===== Badges (Appzia: soft colored, pill shape) ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-dark);
}

/* ===== Modal (Appzia: clean, subtle) ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(49, 58, 70, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.2s ease;
    padding: 24px;
}

@keyframes modalFadeIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius);
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* ===== Admin Layout (Appzia: dark sidebar 255px, white topbar area) ===== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar (Appzia dark sidebar #2a323c) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-header {
    padding: 0 20px;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    position: relative;
}

.logo-full h2, .logo-mini h2 {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    margin: 0;
}

.logo-full span, .logo-mini span {
    color: var(--primary);
}

.logo-mini {
    display: none;
    text-align: center;
    width: 100%;
}

.sidebar.collapsed .logo-full {
    display: none;
}

.sidebar.collapsed .logo-mini {
    display: block;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--sidebar-label);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.sidebar-collapse-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.sidebar.collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
    position: absolute;
    right: -12px;
    top: 50%;
    margin-top: -12px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 16px;
    transition: var(--transition);
}

.sidebar.collapsed .sidebar-nav {
    padding: 12px 8px;
}

/* Appzia sidebar label (section divider) */
.sidebar-divider {
    height: auto;
    background: transparent;
    margin: 12px 0 8px;
    padding: 0 12px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-label);
    font-weight: 700;
    white-space: nowrap;
    transition: var(--transition);
}

.sidebar.collapsed .sidebar-divider {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
    opacity: 0.75;
    white-space: nowrap;
}

.sidebar-nav .nav-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    margin-right: 10px;
    transition: var(--transition);
}

.sidebar-nav a:hover {
    background: rgba(135, 155, 175, 0.12);
    color: white;
    opacity: 1;
}

.sidebar-nav a.active {
    background: rgba(135, 155, 175, 0.12);
    color: white;
    font-weight: 600;
    opacity: 1;
}

.sidebar-nav a.active .nav-icon {
    color: var(--primary);
}

.sidebar.collapsed .sidebar-nav a {
    padding: 12px 0;
    justify-content: center;
    border-radius: var(--radius);
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
    font-size: 1.4rem;
}

.sidebar.collapsed .nav-text {
    display: none;
}

/* ===== Admin Content ===== */
.admin-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    background: var(--bg-content);
    transition: var(--transition);
}

.admin-content.fullwidth {
    margin-left: 70px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.87rem;
    color: var(--text-secondary);
}

/* ===== Stats Grid (Appzia card style: left color accent) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    transition: var(--transition);
}

.stat-card:nth-child(1) { border-left-color: var(--primary); }
.stat-card:nth-child(2) { border-left-color: var(--success); }
.stat-card:nth-child(3) { border-left-color: var(--warning); }
.stat-card:nth-child(4) { border-left-color: var(--danger); }
.stat-card:nth-child(5) { border-left-color: var(--info); }
.stat-card:nth-child(6) { border-left-color: var(--content-primary); }

.stat-card:hover {
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.stat-icon {
    font-size: 1.3rem;
    margin-bottom: 6px;
}

/* ===== Relay Card ===== */
.relay-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
    text-align: center;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.relay-card.relay-on {
    border-color: var(--success);
    background: var(--success-light);
}

.relay-card .relay-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.relay-card .relay-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.relay-card .relay-status {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--text-muted);
    border-radius: 24px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ===== Period Selector ===== */
.period-btn {
    padding: 7px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font);
    font-size: 0.87rem;
    transition: var(--transition);
    color: var(--text-secondary);
}

.period-btn.active,
.period-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    align-items: center;
}

.breadcrumb a {
    color: var(--primary);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Login Page (Appzia auth layout: centered, subtle bg) ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    padding: 20px;
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--sidebar-bg);
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h1 {
    font-size: 1.3rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.login-header h1 span {
    color: var(--primary);
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== pH Scale ===== */
.ph-scale {
    position: relative;
    height: 24px;
    border-radius: 12px;
    background: linear-gradient(to right, #e66060, #f97316, #eab308, #66d203, #66d203, #00a4fe, #7c3aed);
    margin: 20px 0;
    overflow: visible;
}

.ph-marker {
    position: absolute;
    top: -6px;
    width: 3px;
    height: 36px;
    background: var(--text);
    border-radius: 2px;
    transform: translateX(-50%);
}

.ph-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    text-align: center;
    padding: 20px;
    margin-top: 32px;
    font-size: 0.82rem;
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

/* ===== Toast Notification ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.2s ease;
    font-size: 0.9rem;
    max-width: 340px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success {
    background: var(--success);
    color: white;
}

.toast-error {
    background: var(--danger);
    color: white;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success-dark) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.d-flex { display: flex; }
.gap-2 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-100 { width: 100%; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .navbar {
        padding: 0 16px;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-nav {
        display: none;
        position: absolute;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        background: var(--bg-white);
        flex-direction: column;
        padding: 12px;
        box-shadow: var(--shadow-md);
        z-index: 999;
        border-top: 1px solid var(--border);
    }

    .navbar-nav.show {
        display: flex;
    }

    .hero-section h1 {
        font-size: 1.6rem;
    }

    .hero-section {
        padding: 40px 16px;
    }

    /* Sidebar mobile: overlay */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .admin-content {
        margin-left: 0;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card-value {
        font-size: 1.8rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .overview-grid {
        grid-template-columns: 1fr;
        padding: 20px 16px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .sidebar-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1200;
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background: var(--sidebar-bg);
        color: white;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: var(--shadow-md);
        transition: var(--transition);
    }

    .sidebar-toggle-btn:hover {
        background: var(--primary);
    }
}

@media (min-width: 769px) {
    .sidebar-toggle-btn {
        display: none;
    }
}

/* ===== Print Styles ===== */
@media print {
    .navbar, .sidebar, .btn, .filter-bar, .modal-overlay, .sidebar-toggle-btn, .toast-container {
        display: none !important;
    }

    .admin-content {
        margin-left: 0 !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
        color: #333;
    }
}
