/* ============================================
   Sistem Pelaporan 1/3/7 JPN Terengganu
   Mobile-First Responsive CSS
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --primary-50: #eff6ff;
    --secondary: #0d9488;
    --secondary-light: #14b8a6;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --danger: #ef4444;
    --danger-light: #fca5a5;
    --success: #22c55e;
    --success-dark: #16a34a;
    --whatsapp: #25d366;
    --whatsapp-dark: #128c7e;

    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --bg-dark: #0f172a;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}
a:hover { color: var(--primary); }

img { max-width: 100%; }

/* --- Navbar --- */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}
.nav-brand:hover { color: #fff; opacity: 0.9; }

.nav-icon { font-size: 1.3rem; }

.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 1001;
}
.nav-toggle span {
    width: 24px;
    height: 2.5px;
    background: #fff;
    border-radius: 2px;
    transition: var(--transition);
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--primary-dark);
    padding: 8px 0;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
}
.nav-menu.active { display: block; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}
.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-user {
    border-top: 1px solid rgba(255,255,255,0.15);
    margin-top: 8px;
    padding-top: 8px;
}
.nav-user-info {
    padding: 8px 20px;
    display: flex;
    flex-direction: column;
}
.nav-user-name { color: #fff; font-weight: 600; font-size: 0.9rem; }
.nav-user-role { color: rgba(255,255,255,0.6); font-size: 0.8rem; }
.nav-logout { color: var(--danger-light) !important; }

/* --- Container --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

.main-content {
    flex: 1;
    padding: 20px 0;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-50), #fff);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.card-body { padding: 20px; }

/* --- Page Header --- */
.page-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* --- Stat Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    border-left: 4px solid var(--primary-light);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card.stat-warning { border-left-color: var(--accent); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-danger { border-left-color: var(--danger); }

.stat-icon { font-size: 2rem; }

.stat-info {
    display: flex;
    flex-direction: column;
}
.stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    justify-content: center;
    line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: #fff;
}
.btn-success:hover { color: #fff; }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
}
.btn-danger:hover { color: #fff; }

.btn-warning {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #1e293b;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary); }

.btn-whatsapp {
    background: linear-gradient(135deg, var(--whatsapp), var(--whatsapp-dark));
    color: #fff;
    font-size: 1rem;
    padding: 12px 24px;
}
.btn-whatsapp:hover {
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}
.radio-label:hover { border-color: var(--primary-light); }
.radio-label input[type="radio"] { accent-color: var(--primary-light); }
.radio-label input[type="radio"]:checked + span { color: var(--primary); }
.radio-label:has(input:checked) {
    border-color: var(--primary-light);
    background: var(--primary-50);
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.table th {
    background: linear-gradient(135deg, var(--primary-50), #fff);
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--primary-50); }

.table .td-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-draft {
    background: #e2e8f0;
    color: #475569;
}
.badge-semakan {
    background: #fef3c7;
    color: #92400e;
}
.badge-disahkan {
    background: #d1fae5;
    color: #065f46;
}
.badge-selesai {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

/* --- Status Stepper --- */
.status-stepper {
    display: flex;
    overflow-x: auto;
    padding: 16px 0;
    gap: 0;
    -webkit-overflow-scrolling: touch;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 80px;
    position: relative;
    text-align: center;
}

.step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: -50%;
    right: 50%;
    height: 3px;
    background: var(--border);
    z-index: 0;
}
.step:first-child::before { display: none; }
.step.active::before,
.step.done::before { background: var(--success); }

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    z-index: 1;
    transition: var(--transition);
}
.step.done .step-dot {
    background: var(--success);
    color: #fff;
}
.step.active .step-dot {
    background: var(--primary-light);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.25);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.25); }
    50% { box-shadow: 0 0 0 8px rgba(59,130,246,0.1); }
}

.step-label {
    margin-top: 6px;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.2;
}
.step.done .step-label { color: var(--success-dark); }
.step.active .step-label { color: var(--primary); font-weight: 700; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}
.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--accent);
}
.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--primary-light);
}

/* --- Detail Section --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.detail-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-value {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.5;
}

/* --- Ulasan Timeline --- */
.timeline {
    position: relative;
    padding-left: 24px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.timeline-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary-dark);
}
.timeline-date {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.timeline-peringkat {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--secondary);
}
.timeline-content {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.5;
    background: var(--primary-50);
    padding: 10px 14px;
    border-radius: var(--radius);
}

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--secondary) 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
    animation: fadeUp 0.5s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-header .login-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}
.login-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.3;
}
.login-header p {
    color: var(--text-light);
    font-size: 0.88rem;
    margin-top: 4px;
}

/* --- Footer --- */
.footer {
    background: var(--bg-dark);
    color: var(--text-muted);
    text-align: center;
    padding: 16px;
    font-size: 0.82rem;
    margin-top: auto;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.search-box {
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: var(--transition);
}
.search-box input:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.search-box::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* --- WhatsApp Section --- */
.whatsapp-section {
    background: linear-gradient(135deg, #dcfce7, #f0fdf4);
    border: 2px solid #bbf7d0;
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-top: 20px;
}
.whatsapp-section p {
    margin-bottom: 12px;
    color: #166534;
    font-weight: 600;
}

/* --- Action Box --- */
.action-box {
    background: linear-gradient(135deg, var(--primary-50), #fff);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 16px;
}
.action-box h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--primary-dark);
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.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; }
.hidden { display: none !important; }
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================
   Tablet and Desktop Responsive
   ============================================ */
@media (min-width: 640px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .filter-bar {
        flex-direction: row;
        align-items: center;
    }
    .filter-bar .search-box { flex: 1; }
}

@media (min-width: 768px) {
    html { font-size: 16px; }

    .nav-toggle { display: none; }

    .nav-menu {
        display: flex !important;
        position: static;
        background: none;
        box-shadow: none;
        padding: 0;
        align-items: center;
        gap: 4px;
        animation: none;
    }

    .nav-link {
        padding: 8px 14px;
        border-radius: var(--radius);
        font-size: 0.88rem;
    }
    .nav-link:hover {
        background: rgba(255,255,255,0.15);
    }

    .nav-user {
        border-top: none;
        margin-top: 0;
        padding-top: 0;
        display: flex;
        align-items: center;
        gap: 12px;
        margin-left: 8px;
        padding-left: 12px;
        border-left: 1px solid rgba(255,255,255,0.2);
    }
    .nav-user-info {
        padding: 0;
    }

    .main-content {
        padding: 32px 0;
    }

    .card-body { padding: 24px; }

    .page-header h1 { font-size: 1.6rem; }

    .login-card { padding: 40px 36px; }
}

@media (min-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* --- Print Styles --- */
@media print {
    .navbar, .footer, .btn, .nav-toggle,
    .filter-bar, .action-box, .whatsapp-section { display: none !important; }
    body { background: #fff; }
    .main-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .badge { border: 1px solid #999; }
}
