/* ===== Theme Variables ===== */
:root {
    --bg-body-start: #f8fafc;
    --bg-body-end: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-faint: #cbd5e1;
    --bg-card: rgba(255,255,255,0.7);
    --bg-card-solid: rgba(255,255,255,0.6);
    --bg-input: rgba(255,255,255,0.8);
    --border-subtle: rgba(148,163,184,0.12);
    --border-medium: rgba(148,163,184,0.15);
    --border-card: rgba(148,163,184,0.3);
    --shadow-sm: rgba(0,0,0,0.04);
    --shadow-md: rgba(0,0,0,0.08);
    --shadow-lg: rgba(0,0,0,0.15);
    --shadow-xl: rgba(0,0,0,0.2);
    --bg-modal: #ffffff;
    --bg-modal-summary: rgba(248,250,252,1);
    --bg-overlay: rgba(15,23,42,0.6);
    --bg-submit-bar-start: rgba(248,250,252,1);
    --bg-submit-bar-end: rgba(248,250,252,0);
    --bg-btn-disabled: rgba(148,163,184,0.2);
    --bg-btn-history: rgba(148,163,184,0.1);
    --bg-btn-history-hover: rgba(148,163,184,0.2);
    --bg-btn-cancel: rgba(148,163,184,0.12);
    --color-blue: #3b82f6;
    --color-green: #22c55e;
    --color-green-dark: #16a34a;
    --color-red: #ef4444;
    --color-amber: #f59e0b;
    --color-amber-dark: #d97706;
    --color-amber-light: #fbbf24;
    --bg-card-required: rgba(239,68,68,0.04);
    --border-card-required: rgba(239,68,68,0.3);
    --bg-card-success: rgba(34,197,94,0.06);
    --border-card-success: rgba(34,197,94,0.3);
    --bg-alert-error: rgba(239,68,68,0.08);
    --border-alert-error: rgba(239,68,68,0.2);
    --bg-onedrive-btn: rgba(59,130,246,0.1);
    --bg-new-sub-start: #1e293b;
    --bg-new-sub-end: #334155;
    --progress-track: rgba(148,163,184,0.15);
    --scrollbar-thumb: rgba(148,163,184,0.3);
    --photo-thumb-border: rgba(255,255,255,0.8);
    --photo-thumb-remove-border: white;
    --select-arrow: %2394a3b8;
    --focus-ring: rgba(245,158,11,0.1);
    --shadow-success: rgba(34,197,94,0.3);
    --shadow-amber: rgba(245,158,11,0.35);
    --shadow-amber-sm: rgba(245,158,11,0.25);
    --shadow-amber-modal: rgba(245,158,11,0.3);
    --header-logo-bg: #e2e8f0;
    --testing-text: #78350f;
    --theme-color: #f8fafc;
}

[data-theme="dark"] {
    --bg-body-start: #0f172a;
    --bg-body-end: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #475569;
    --bg-card: rgba(30,41,59,0.7);
    --bg-card-solid: rgba(30,41,59,0.6);
    --bg-input: rgba(15,23,42,0.6);
    --border-subtle: rgba(148,163,184,0.2);
    --border-medium: rgba(148,163,184,0.25);
    --border-card: rgba(148,163,184,0.3);
    --shadow-sm: rgba(0,0,0,0.15);
    --shadow-md: rgba(0,0,0,0.25);
    --shadow-lg: rgba(0,0,0,0.35);
    --shadow-xl: rgba(0,0,0,0.4);
    --bg-modal: #1e293b;
    --bg-modal-summary: rgba(15,23,42,1);
    --bg-overlay: rgba(0,0,0,0.7);
    --bg-submit-bar-start: rgba(15,23,42,1);
    --bg-submit-bar-end: rgba(15,23,42,0);
    --bg-btn-disabled: rgba(71,85,105,0.3);
    --bg-btn-history: rgba(148,163,184,0.15);
    --bg-btn-history-hover: rgba(148,163,184,0.25);
    --bg-btn-cancel: rgba(71,85,105,0.3);
    --color-blue: #60a5fa;
    --color-green: #4ade80;
    --color-green-dark: #22c55e;
    --color-red: #f87171;
    --color-amber: #fbbf24;
    --color-amber-dark: #f59e0b;
    --color-amber-light: #fcd34d;
    --bg-card-required: rgba(239,68,68,0.08);
    --border-card-required: rgba(239,68,68,0.35);
    --bg-card-success: rgba(34,197,94,0.1);
    --border-card-success: rgba(34,197,94,0.35);
    --bg-alert-error: rgba(239,68,68,0.12);
    --border-alert-error: rgba(239,68,68,0.3);
    --bg-onedrive-btn: rgba(96,165,250,0.15);
    --bg-new-sub-start: #334155;
    --bg-new-sub-end: #475569;
    --progress-track: rgba(71,85,105,0.4);
    --scrollbar-thumb: rgba(148,163,184,0.4);
    --photo-thumb-border: rgba(30,41,59,0.8);
    --photo-thumb-remove-border: #1e293b;
    --select-arrow: %2394a3b8;
    --focus-ring: rgba(251,191,36,0.15);
    --shadow-success: rgba(74,222,128,0.25);
    --shadow-amber: rgba(251,191,36,0.3);
    --shadow-amber-sm: rgba(251,191,36,0.2);
    --shadow-amber-modal: rgba(251,191,36,0.25);
    --header-logo-bg: #334155;
    --testing-text: #78350f;
    --theme-color: #1e293b;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0; padding: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--bg-body-start) 0%, var(--bg-body-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ===== Testing Banner ===== */
.testing-banner {
    background: linear-gradient(135deg, var(--color-amber-light), var(--color-amber));
    color: var(--testing-text);
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow-amber-sm);
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

/* ===== Header ===== */
.app-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.header-icon {
    width: 40px; height: 40px;
    min-width: 40px; min-height: 40px;
    max-width: 40px; max-height: 40px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.header-icon-img {
    display: block;
    width: 40px; height: 40px;
    max-width: 40px; max-height: 40px;
    object-fit: cover;
    border-radius: 10px;
}

.header-logo {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--header-logo-bg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px var(--shadow-md);
}
.header-logo img {
    width: 42px; height: 42px;
    object-fit: contain;
    padding: 3px;
}

.header-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px; font-weight: 700;
    color: var(--text-primary); margin: 0; line-height: 1.1;
}

.header-subtitle {
    font-size: 11px; color: var(--text-muted);
    letter-spacing: 0.5px; text-transform: uppercase;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-btn-history);
    border: none; border-radius: 10px;
    width: 38px; height: 38px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-btn-history-hover); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; color: #fbbf24; }
.theme-toggle .icon-moon { display: block; color: var(--text-secondary); }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.btn-history {
    background: var(--bg-btn-history);
    border: none; border-radius: 10px;
    padding: 8px 12px; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px; color: var(--text-secondary); font-weight: 600;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
    transition: background 0.2s;
}
.btn-history:hover { background: var(--bg-btn-history-hover); }

/* ===== Form ===== */
.form-body {
    padding: 20px 16px;
    display: flex; flex-direction: column; gap: 16px;
}

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

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid var(--border-medium);
    background: var(--bg-input);
    font-size: 15px;
    font-family: 'DM Mono', 'DM Sans', sans-serif;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='var(--select-arrow)' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.form-select.placeholder { color: var(--text-muted); }

.form-textarea {
    resize: vertical; min-height: 70px;
    font-family: 'DM Sans', sans-serif;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-amber);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

@media screen and (max-width: 768px) {
    .form-input, .form-select, .form-textarea { font-size: 16px !important; }
}

/* ===== Section Headers ===== */
.section-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}

.section-title {
    font-size: 13px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
}
.section-title--required { color: var(--text-primary); }
.section-title--optional { color: var(--text-muted); }

.section-badge {
    border-radius: 6px; padding: 1px 8px;
    font-size: 11px; font-weight: 600; color: white;
}
.section-badge--ok { background: var(--color-green); }
.section-badge--pending { background: var(--color-red); }

/* ===== Photo Cards ===== */
.photo-card {
    border-radius: 16px; padding: 16px;
    transition: all 0.2s ease;
}
.photo-card--required {
    background: var(--bg-card-required);
    border: 2px dashed var(--border-card-required);
}
.photo-card--optional {
    background: var(--bg-card-solid);
    border: 2px dashed var(--border-card);
}
.photo-card--has-photos {
    background: var(--bg-card-success) !important;
    border: 2px solid var(--border-card-success) !important;
}

.photo-card-header {
    display: flex; align-items: center; justify-content: space-between;
}
.photo-card-info {
    display: flex; align-items: center; gap: 10px;
}
.photo-card-icon { font-size: 22px; width: 28px; text-align: center; }
.photo-card-label { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.photo-card-status { font-size: 11px; font-weight: 500; }
.photo-card-status--required { color: var(--color-red); }
.photo-card-status--count { color: var(--color-green); }

/* Photo buttons container */
.photo-btns {
    display: flex; gap: 6px;
    flex-shrink: 0;
}

/* Photo button */
.btn-photo {
    border: none; border-radius: 10px;
    padding: 8px 12px; font-size: 12px;
    font-family: 'DM Sans', sans-serif; font-weight: 600;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
    color: white;
    transition: transform 0.1s ease;
}
.btn-photo:active { transform: scale(0.95); }
.btn-photo--required { background: var(--color-blue); }
.btn-photo--optional { background: var(--text-secondary); }
.btn-photo--camera { background: var(--color-blue); }
.btn-photo--gallery { background: var(--text-secondary); }
.btn-photo--has-photos { background: var(--color-green); }

/* Photo thumbnails */
.photo-thumbs {
    display: flex; gap: 8px;
    overflow-x: auto; padding-top: 12px; padding-bottom: 4px;
}
.photo-thumbs::-webkit-scrollbar { height: 4px; }
.photo-thumbs::-webkit-scrollbar-track { background: transparent; }
.photo-thumbs::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

.photo-thumb { position: relative; flex-shrink: 0; }
.photo-thumb img {
    width: 72px; height: 72px;
    object-fit: cover; border-radius: 10px;
    border: 2px solid var(--photo-thumb-border);
    box-shadow: 0 2px 8px var(--shadow-md);
}
.photo-thumb-remove {
    position: absolute; top: -6px; right: -6px;
    background: var(--color-red); color: white;
    border: 2px solid var(--photo-thumb-remove-border); border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; line-height: 1;
}

/* ===== Submit Bar ===== */
.submit-bar {
    position: sticky; bottom: 0;
    padding: 16px; padding-top: 32px;
    background: linear-gradient(to top, var(--bg-submit-bar-start) 70%, var(--bg-submit-bar-end));
}

.submit-validation-msg {
    text-align: center; margin-bottom: 10px;
    font-size: 12px; color: var(--color-red);
}

.btn-submit {
    width: 100%; padding: 16px;
    border-radius: 14px; border: none;
    font-size: 16px; font-family: 'DM Sans', sans-serif; font-weight: 700;
    cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-submit--active {
    background: linear-gradient(135deg, var(--color-amber), var(--color-amber-dark));
    color: white;
    box-shadow: 0 4px 20px var(--shadow-amber);
}
.btn-submit--disabled {
    background: var(--bg-btn-disabled);
    color: var(--text-muted); cursor: not-allowed;
}
.btn-submit--loading {
    background: linear-gradient(135deg, var(--color-amber), var(--color-amber-dark));
    color: white; opacity: 0.8; cursor: wait;
}

/* ===== Progress Bar ===== */
.progress-container { margin-bottom: 12px; }
.progress-info {
    display: flex; justify-content: space-between;
    margin-bottom: 6px; font-size: 12px; color: var(--text-secondary);
}
.progress-track {
    height: 6px; background: var(--progress-track);
    border-radius: 3px; overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-amber), var(--color-amber-dark));
    border-radius: 3px; transition: width 0.3s ease;
}

/* ===== Success Screen ===== */
.success-screen {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 70vh; text-align: center;
    padding: 32px; animation: fadeIn 0.4s ease;
}

.success-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-green), var(--color-green-dark));
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px var(--shadow-success);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-title {
    font-family: 'Playfair Display', serif;
    font-size: 26px; color: var(--text-primary);
    margin: 0 0 8px;
}
.success-obra {
    color: var(--text-secondary); font-size: 15px; margin: 0 0 8px;
}
.success-details {
    color: var(--text-muted); font-size: 13px; margin: 0 0 32px;
}

.btn-new-submission {
    background: linear-gradient(135deg, var(--bg-new-sub-start), var(--bg-new-sub-end));
    color: white; border: none; border-radius: 14px;
    padding: 14px 32px; font-size: 15px;
    font-family: 'DM Sans', sans-serif; font-weight: 600;
    cursor: pointer; box-shadow: 0 4px 16px var(--shadow-lg);
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 8px;
    margin-bottom: 12px;
}

/* Drive status banners */
.drive-warning {
    background: rgba(245,158,11,0.12);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-amber-dark);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 320px;
    text-align: left;
}
.drive-warning svg { flex-shrink: 0; margin-top: 1px; }

.drive-error {
    background: var(--bg-alert-error);
    border: 1px solid var(--border-alert-error);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-red);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 320px;
    text-align: left;
}
.drive-error svg { flex-shrink: 0; margin-top: 1px; }

.btn-onedrive {
    background: var(--bg-onedrive-btn);
    color: var(--color-blue); border: none; border-radius: 14px;
    padding: 12px 28px; font-size: 14px;
    font-family: 'DM Sans', sans-serif; font-weight: 600;
    cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; gap: 8px;
}

.summary-card {
    background: var(--bg-card); border-radius: 14px;
    padding: 16px 20px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 4px var(--shadow-sm);
    margin-bottom: 24px; width: 100%; max-width: 320px;
    text-align: left;
}
.summary-row {
    display: flex; justify-content: space-between;
    padding: 6px 0; font-size: 14px;
}
.summary-label { color: var(--text-muted); font-size: 13px; }
.summary-value { color: var(--text-primary); font-weight: 600; font-size: 13px; }

/* ===== History ===== */
.history-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-medium);
    margin-bottom: 16px;
}
.btn-back {
    background: none; border: none; cursor: pointer;
    padding: 4px 8px; color: var(--color-blue); font-size: 20px;
    text-decoration: none; display: flex;
}
.history-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px; color: var(--text-primary); margin: 0;
}
.history-count { font-size: 13px; color: var(--text-muted); margin-left: auto; }

.history-list {
    padding: 0 16px; display: flex; flex-direction: column; gap: 10px;
    padding-bottom: 32px;
}

.history-item {
    background: var(--bg-card); border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 4px var(--shadow-sm);
    display: flex; justify-content: space-between; align-items: start;
    text-decoration: none; color: inherit;
}
.history-obra {
    font-family: 'DM Mono', monospace;
    font-weight: 700; font-size: 15px; color: var(--text-primary);
}
.history-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.history-photos-badge {
    background: var(--color-green); color: white;
    border-radius: 8px; padding: 2px 10px;
    font-size: 12px; font-weight: 600;
}
.history-date { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.history-empty { color: var(--text-muted); text-align: center; padding: 40px 0; }

/* ===== Alert ===== */
.alert-error {
    background: var(--bg-alert-error);
    border: 1px solid var(--border-alert-error);
    border-radius: 12px; padding: 12px 16px;
    color: var(--color-red); font-size: 13px; font-weight: 500;
    margin: 0 16px;
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 24px 16px 32px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 16px;
}
.footer-company {
    font-size: 12px; color: var(--text-muted);
    font-weight: 500;
}
.footer-version {
    font-size: 11px; color: var(--text-faint);
    margin-top: 2px;
}

/* ===== Confirmation Modal ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}
.modal-content {
    background: var(--bg-modal);
    border-radius: 20px;
    padding: 28px 24px 24px;
    width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px var(--shadow-xl);
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-header {
    text-align: center; margin-bottom: 20px;
}
.modal-icon {
    font-size: 36px;
    display: block; margin-bottom: 8px;
}
.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 22px; color: var(--text-primary);
    margin: 0;
}
.modal-summary {
    background: var(--bg-modal-summary);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-subtle);
}
.modal-summary-row {
    display: flex; justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}
.modal-summary-label {
    color: var(--text-muted);
}
.modal-summary-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}
.modal-summary-divider {
    height: 1px;
    background: var(--border-medium);
    margin: 6px 0;
}
.modal-actions {
    display: flex; gap: 10px;
}
.modal-btn {
    flex: 1; padding: 14px;
    border-radius: 12px; border: none;
    font-size: 14px; font-family: 'DM Sans', sans-serif;
    font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all 0.15s ease;
}
.modal-btn:active { transform: scale(0.97); }
.modal-btn--cancel {
    background: var(--bg-btn-cancel);
    color: var(--text-secondary);
}
.modal-btn--confirm {
    background: linear-gradient(135deg, var(--color-amber), var(--color-amber-dark));
    color: white;
    box-shadow: 0 4px 16px var(--shadow-amber-modal);
}

/* ===== Admin (uses Bootstrap separately) ===== */
.admin-page { max-width: 960px; margin: 0 auto; padding: 20px; }

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
