:root {
    --primary-gradient: linear-gradient(135deg, #a1887f 0%, #8d6e63 100%);
    --bg-gradient: linear-gradient(180deg, #fdf8f5 0%, #f4e8e0 100%);
    --primary: #8d6e63;
    --primary-dark: #5d4037;
    --success: #6d4c41;
    --success-light: #d7ccc8;
    --danger: #d84315;
    --bg: #fdf8f5;
    --card-bg: #ffffff;
    --text-main: #3e2723;
    --text-muted: #795548;
    --header-height: 130px;
    --footer-height: 50px;
    --radius: 16px;
}

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

body {
    margin: 0;
    padding: 0;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Header Styling */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-gradient);
    color: white;
    padding: 20px 20px 10px 20px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: background 0.2s;
}

.icon-btn:active {
    background: rgba(255,255,255,0.3);
}

.search-container {
    position: relative;
    width: 100%;
    margin-top: 10px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

#search-input {
    width: 100%;
    padding: 12px 12px 12px 44px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#search-input::placeholder {
    color: #a1887f;
}

/* Main Content */
main {
    margin-top: var(--header-height);
    padding: 20px;
    padding-bottom: calc(var(--footer-height) + 20px);
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Pilgrim List */
.pilgrim-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pilgrim-card {
    background: var(--card-bg);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(93, 64, 55, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(215, 204, 200, 0.3);
}

.pilgrim-card:active {
    transform: scale(0.97);
    background-color: #fcfaf9;
}

.pilgrim-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.pilgrim-info p {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.done { background: #efebe9; color: #5d4037; }
.badge.pending { background: #fbe9e7; color: #d84315; }

/* Detail View */
.back-btn {
    background: none;
    border: none;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    padding: 8px 0;
    cursor: pointer;
    margin-bottom: 20px;
}

.detail-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.08);
    border: 1px solid rgba(215, 204, 200, 0.2);
}

.detail-card h2 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: var(--primary-dark);
    border-bottom: 2px solid #efebe9;
    padding-bottom: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-item label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-item span {
    font-weight: 500;
    color: var(--text-main);
    font-size: 14px;
}

/* Forms */
.action-form {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.08);
}

.action-form h3 {
    margin-top: 0;
    font-size: 18px;
    color: var(--primary-dark);
}

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

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 14px;
    border: 1.5px solid #d7ccc8;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

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

.capture-btn {
    width: 100%;
    padding: 18px;
    background: #fdf8f5;
    border: 2px dashed #d7ccc8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
    transition: all 0.2s;
}

/* New Camera Styles */
.camera-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.camera-preview-box {
    width: 100%;
    aspect-ratio: 3/4;
    background: #efebe9;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 2px solid #d7ccc8;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#camera-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-watermark-preview {
    position: absolute;
    inset: auto 0 0 0;
    padding: 8%;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.35) 38%, rgba(0, 0, 0, 0.78) 100%);
}

.watermark-panel {
    min-height: 92px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.watermark-panel strong,
.watermark-panel span,
.watermark-panel small {
    display: block;
    line-height: 1.2;
}

.watermark-panel strong {
    font-size: 18px;
    font-weight: 700;
}

.watermark-panel span {
    margin-top: 3px;
    font-size: 11px;
    font-weight: 500;
}

.watermark-panel small {
    margin-top: 4px;
    font-size: 10px;
    font-weight: 500;
}

#watermark-preview-porsi {
    white-space: nowrap;
    text-align: right;
    padding-bottom: 1px;
}

.camera-placeholder {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    gap: 10px;
}

.camera-placeholder p {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.camera-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.capture-btn:active {
    background: #efebe9;
}

.photo-preview {
    margin-top: 15px;
    border-radius: 12px;
    overflow: hidden;
    max-height: 250px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.submit-btn {
    width: 100%;
    padding: 18px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(141, 110, 99, 0.3);
    margin-top: 10px;
}

.submit-btn:disabled {
    background: #d7ccc8;
    box-shadow: none;
}

/* Status Card */
.status-card {
    background: white;
    padding: 30px 24px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.08);
}

.success-icon {
    width: 56px;
    height: 56px;
    color: #4e342e;
    margin-bottom: 16px;
}

.status-card p {
    margin: 8px 0;
}

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

.proof-photo {
    margin-top: 20px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.proof-photo img {
    width: 100%;
    display: block;
}

/* Report Styling */
.report-header {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.08);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    text-align: center;
}

.stat-item .label { font-size: 10px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.stat-item .value { display: block; font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.stat-item.success .value { color: #5d4037; }
.stat-item.pending .value { color: var(--danger); }

.progress-bar {
    height: 10px;
    background: #efebe9;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.report-tabs {
    display: flex;
    background: #efebe9;
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    border: none;
    padding: 12px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 13px;
    background: none;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tab-btn.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(93, 64, 55, 0.1);
}

/* Footer Styling */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: rgba(253, 248, 245, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    border-top: 1px solid rgba(215, 204, 200, 0.3);
    z-index: 90;
}

/* Helpers */
.hidden { display: none !important; }

.toast {
    position: fixed;
    bottom: 70px;
    left: 20px;
    right: 20px;
    background: rgba(62, 39, 35, 0.95);
    color: white;
    padding: 16px;
    border-radius: 14px;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s;
}

.loading {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-muted);
    font-weight: 500;
}

.spin {
    animation: rotate 1s linear infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
