/* ============================================
   Sistem Absensi Kedinasan — Stylesheet
   Theme: Merah-Putih Formal (Pemerintah)
   Mobile-first responsive design
   ============================================ */

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

:root {
    --primary: #1F4529;
    --primary-dark: #122c19;
    --primary-light: #326e42;
    --primary-glow: rgba(31, 69, 41, 0.15);
    --accent: #D7A022;
    --gold: #D7A022;
    --gold-light: #f7ebce;
    --bg: #F9FAEB;
    --bg-card: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --text: #1A1A2E;
    --text-secondary: #5A5A72;
    --text-light: #8A8AA0;
    --border: #E8E0D8;
    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --warning: #E65100;
    --warning-bg: #FFF3E0;
    --info: #1565C0;
    --info-bg: #E3F2FD;
    --error: #C62828;
    --error-bg: #FFEBEE;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    --shadow-glow: 0 4px 20px rgba(31, 69, 41, 0.2);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(31, 69, 41, 0.3);
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-circle {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
}

.header-text h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.header-text p {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* ---- Live Clock ---- */
.live-clock {
    text-align: right;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.1);
}

.clock-time {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.clock-date {
    font-size: 10px;
    opacity: 0.75;
    font-weight: 400;
}

/* ---- Status Banner ---- */
.status-banner {
    max-width: 600px;
    margin: 12px auto 0;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-left: auto;
    margin-right: auto;
    width: calc(100% - 32px);
}

.status-banner.active {
    color: var(--success);
    background: var(--success-bg);
}

.status-banner.inactive {
    color: var(--warning);
    background: var(--warning-bg);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    flex-shrink: 0;
}

.status-banner.active .status-dot {
    background: var(--success);
    animation: pulse-dot 2s infinite;
}

.status-banner.inactive .status-dot {
    background: var(--warning);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ---- Container ---- */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Tab Navigation ---- */
.tab-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius) - 2px);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.tab-content {
    display: none;
    animation: fadeSlideUp 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* ---- Form Card ---- */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.form-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-child {
    border-bottom: none;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
}

.section-title svg {
    color: var(--primary-light);
}

/* ---- Form Groups ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.label-hint {
    font-weight: 400;
    color: var(--text-light);
    font-size: 12px;
}

.required-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--error-bg);
    color: var(--error);
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.optional-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--info-bg);
    color: var(--info);
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="text"]::placeholder {
    color: var(--text-light);
}

.nip-counter {
    text-align: right;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.field-error {
    display: block;
    font-size: 12px;
    color: var(--error);
    margin-top: 4px;
    min-height: 0;
    transition: var(--transition);
}

/* ---- Upload Area ---- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary-light);
    background: var(--primary-glow);
}

.upload-placeholder {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-light);
}

.upload-placeholder svg {
    margin-bottom: 8px;
    opacity: 0.5;
}

.upload-placeholder p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.upload-hint {
    font-size: 11px;
    display: block;
    margin-top: 4px;
}

.upload-preview {
    position: relative;
    background: #000;
    border-radius: var(--radius);
}

.upload-preview img {
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    display: block;
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-btn:hover {
    background: var(--error);
}

.upload-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    background: var(--info-bg);
    color: var(--info);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
}

.upload-file-info svg {
    flex-shrink: 0;
}

.upload-file-info span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-btn-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--info);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.remove-btn-small:hover {
    background: var(--error);
}

/* ---- Input with Button ---- */
.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.search-btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-glow);
}

.search-btn:active {
    transform: scale(0.97);
}

/* ---- Record Card ---- */
.record-card {
    margin-top: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeSlideUp 0.3s ease;
}

.record-header {
    padding: 12px 16px;
    background: var(--success-bg);
}

.record-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.record-details {
    padding: 12px 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 13px;
    color: var(--text-light);
}

.detail-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-align: right;
}

/* ---- Submit Button ---- */
.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.form-card .submit-btn {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.submit-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    box-shadow: var(--shadow-glow);
}

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

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.submit-pulang {
    margin: 0 16px 16px;
    width: calc(100% - 32px);
    border-radius: var(--radius) !important;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ---- Alert Cards ---- */
.alert-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 16px;
    animation: fadeSlideUp 0.3s ease;
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
}

.alert-card svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ---- Success Screen ---- */
.success-screen {
    text-align: center;
    padding: 40px 20px;
    animation: fadeSlideUp 0.5s ease;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    animation: successPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes successPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.success-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.success-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.success-recap {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: left;
    overflow: hidden;
    margin-bottom: 24px;
}

.success-recap .detail-row {
    padding: 10px 20px;
}

.success-screen .submit-btn {
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--success), #1B5E20);
}

.success-screen .submit-btn:hover {
    box-shadow: 0 4px 20px rgba(46, 125, 50, 0.3);
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 24px 16px 32px;
    color: var(--text-light);
    font-size: 12px;
}

.footer-sub {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

/* ---- Toast Notification ---- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: calc(100% - 32px);
    text-align: center;
}

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

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

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

/* ---- Responsive ---- */
@media (min-width: 640px) {
    .header-content {
        padding: 20px 24px;
    }

    .header-text h1 {
        font-size: 18px;
    }

    .clock-time {
        font-size: 24px;
    }

    .container {
        padding: 20px;
    }

    .form-section {
        padding: 24px;
    }
}

/* ---- Admin Styles ---- */
.admin-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(31, 69, 41, 0.3);
}

.admin-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

.admin-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ---- Filters ---- */
.filter-bar {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 160px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-glow);
}

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

.btn-success:hover {
    background: #1B5E20;
}

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

.btn-info:hover {
    background: #0D47A1;
}

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

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

/* ---- Stats Cards ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ---- Data Table ---- */
.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

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

.data-table tbody tr:hover {
    background: var(--primary-glow);
}

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

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

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

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

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

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--info-bg);
    color: var(--info);
    border-radius: 6px;
    font-size: 11px;
    text-decoration: none;
    transition: var(--transition);
}

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

.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 14px;
}

.table-footer {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---- Export Buttons ---- */
.export-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ---- Responsive Admin ---- */
@media (max-width: 768px) {
    .admin-header-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-group {
        min-width: unset;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}
