/* Policy Review PWA - Prudential Red Theme */
:root {
    --red: #ED1B2E;
    --red-dark: #C41230;
    --red-pale: #FFF0F1;
    --green: #2E7D32;
    --green-bg: #E8F5E9;
    --amber: #E65100;
    --amber-bg: #FFF3E0;
    --text: #1A1A1A;
    --text-secondary: #666;
    --text-light: #999;
    --bg: #F8F8F8;
    --white: #FFFFFF;
    --border: #E8E8E8;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--red);
    color: var(--white);
    text-align: center;
    padding: 12px 20px;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(237,27,46,0.3);
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Main */
main {
    flex: 1;
    padding: 20px 16px;
    padding-bottom: calc(32px + var(--safe-bottom));
}

/* Upload */
.upload-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px dashed var(--border);
}

.upload-icon { font-size: 56px; margin-bottom: 16px; }

.upload-card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.upload-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.hint {
    font-size: 12px !important;
    color: var(--text-light) !important;
    margin-bottom: 0 !important;
}

/* Buttons */
.btn-primary {
    background: var(--red);
    color: var(--white);
    border: none;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { background: var(--red-dark); transform: scale(0.98); }

.btn-secondary {
    background: var(--white);
    color: var(--red);
    border: 2px solid var(--red);
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: var(--red-pale); transform: scale(0.98); }

.btn-outline {
    background: none;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Preview */
.preview-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.preview-card img {
    width: 100%;
    display: block;
    max-height: 60vh;
    object-fit: contain;
    background: #000;
}

.preview-actions {
    display: flex;
    gap: 10px;
    padding: 16px;
}

/* Loading */
.loading-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 60px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--red-pale);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-card h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.loading-card p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Results */
.results-header.overdue {
    background: linear-gradient(135deg, #B71C1C, #E53935);
}

.info-value.status-badge {
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.info-value.status-badge.inforce {
    color: var(--green);
    background: var(--green-bg);
}

.info-value.status-badge.overdue {
    color: #C62828;
    background: #FFEBEE;
}

.premium-block .period-detail {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 10px;
    margin-top: -4px;
}

.premium-block.overdue-block {
    border-left-color: #C62828;
    background: #FFF5F5;
}

.premium-block.overdue-block .period {
    color: #C62828;
}

.premium-block.overdue-block .amount-value {
    color: #C62828;
}

.results-header {
    background: linear-gradient(135deg, var(--red-dark), var(--red));
    color: var(--white);
    padding: 20px;
}

.results-header .policy-number {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.results-header .insured-name {
    font-size: 22px;
    font-weight: 800;
}

.results-header .company {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
}

.results-body {
    padding: 20px;
}

/* Info rows */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 70px;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    flex: 1;
    min-width: 0;
}

.info-value.status-inforce {
    color: var(--green);
    background: var(--green-bg);
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
}

/* Premium sections */
.premium-section {
    margin-top: 20px;
    border-top: 2px solid var(--red);
    padding-top: 16px;
}

.premium-section h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 12px;
}

.premium-block {
    background: #FAFAFA;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--red);
}

.premium-block.current {
    border-left-color: var(--amber);
    background: var(--amber-bg);
}

.premium-block.next {
    border-left-color: var(--green);
    background: var(--green-bg);
}

.premium-block .period {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.premium-block.current .period { color: var(--amber); }
.premium-block.next .period { color: var(--green); }

.premium-amounts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.amount-item {
    text-align: center;
    padding: 8px;
    background: var(--white);
    border-radius: 8px;
}

.amount-item .currency-label {
    font-size: 10px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.amount-item .amount-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.premium-block.current .amount-value { color: var(--amber); }
.premium-block.next .amount-value { color: var(--green); }

.levy-info {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 8px;
}

/* Due date badge */
.due-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    margin-top: 8px;
}

.due-badge.overdue {
    background: #FFEBEE;
    color: var(--red);
}

.due-badge.upcoming {
    background: var(--amber-bg);
    color: var(--amber);
}

/* Editable inputs */
.editable-input {
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 2px 4px;
    border-radius: 4px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

.editable-input:focus {
    border-color: var(--red);
    background: #FFF5F5;
}

/* Header inputs */
.policy-number-input.editable-input {
    font-size: 13px;
    opacity: 0.85;
    width: auto;
    min-width: 150px;
}

.insured-name-input.editable-input {
    font-size: 22px;
    font-weight: 800;
    width: auto;
    min-width: 200px;
}

.company-input.editable-input {
    font-size: 13px;
    opacity: 0.85;
    width: auto;
}

/* Info value inputs */
.info-value.editable-input {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    width: auto;
    min-width: 100px;
}

/* Address value */
.address-value.editable-input {
    font-size: 12px;
    max-width: 75%;
    line-height: 1.4;
    text-align: right;
    resize: vertical;
    min-height: 36px;
    width: 100%;
}

.address-row {
    align-items: flex-start !important;
}

.address-row .info-label {
    padding-top: 4px;
}

/* Period detail & amount inputs */
.period-detail-input.editable-input {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
    width: auto;
    min-width: 200px;
}

.amount-input.editable-input {
    font-size: 16px;
    font-weight: 800;
    text-align: center;
    width: 100px;
    color: inherit;
}

.amount-input.editable-input:focus {
    background: #FFF5F5;
}

/* Plan Cards (multi-plan support) */
.plan-card {
    background: #FAFAFA;
    border: 1px solid #E8E8E8;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.plan-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #FFF5F5, #FFF0F1);
    border-bottom: 1px solid #F5C6CB;
}

.plan-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--red);
    background: var(--red-pale);
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.plan-name-input.editable-input {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    flex: 1;
    min-width: 0;
}

.plan-status {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    background: #E8F5E9;
    color: #2E7D32;
    white-space: nowrap;
}

.plan-body {
    padding: 12px 16px;
}

.plan-body .info-row {
    padding: 8px 0;
}

.results-actions .btn-primary {
    width: auto;
    padding: 14px 40px;
}

/* Download card */
.download-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.download-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FFF5F5;
    border: 2px dashed var(--red);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: background 0.15s;
}

.download-card:active {
    background: #FFEBEE;
}

.download-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.download-info {
    flex: 1;
    min-width: 0;
}

.download-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 2px;
}

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

.download-arrow {
    font-size: 20px;
    color: var(--red);
    flex-shrink: 0;
}

/* Error */
.error-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.error-icon { font-size: 48px; margin-bottom: 16px; }

.error-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 8px;
}

.error-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}
