/* ========================================
   Matrimony Tracker - CSS
   Mobile-first, elderly-friendly design
   ======================================== */

/* CSS Reset & Variables */
:root {
    --primary: #B5451B;
    --primary-dark: #8C3515;
    --primary-light: #D4693E;
    --bg: #FAF7F4;
    --bg-card: #FFFFFF;
    --text: #2D2D2D;
    --text-secondary: #6B6B6B;
    --border: #E0D8D0;
    --success: #2E7D32;
    --warning: #ED6C02;
    --danger: #D32F2F;
    --info: #1976D2;
    --status-new: #78909C;
    --status-contacted: #1976D2;
    --status-conversation: #F9A825;
    --status-waiting: #ED6C02;
    --status-shortlisted: #2E7D32;
    --status-rejected: #D32F2F;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-sm: 14px;
    --tap-size: 48px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
    font-size: var(--font-size-base);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ========================================
   Form Elements
   ======================================== */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: var(--font-size-lg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: var(--font-size-lg);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    min-height: var(--tap-size);
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}

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

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

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

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

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

.btn-block {
    width: 100%;
}

/* ========================================
   Top Bar
   ======================================== */
.top-bar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    padding-bottom: calc(80px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.view {
    display: none;
    padding: 16px;
}

.view.active {
    display: block;
}

/* ========================================
   Search
   ======================================== */
.search-container {
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    font-size: var(--font-size-lg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========================================
   Filter Cards
   ======================================== */
.filter-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.filter-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    min-height: var(--tap-size);
}

.filter-card:active {
    transform: scale(0.96);
}

.filter-card.active {
    border-color: var(--primary);
    background: rgba(181, 69, 27, 0.08);
}

.filter-count {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.filter-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* ========================================
   Profile Cards
   ======================================== */
.profile-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    transition: transform 0.15s;
    cursor: pointer;
}

.profile-card:active {
    transform: scale(0.98);
}

.profile-card.status-New { border-left-color: var(--status-new); }
.profile-card.status-Contacted { border-left-color: var(--status-contacted); }
.profile-card.status-Conversation { border-left-color: var(--status-conversation); }
.profile-card.status-Waiting { border-left-color: var(--status-waiting); }
.profile-card.status-Shortlisted { border-left-color: var(--status-shortlisted); }
.profile-card.status-Rejected { border-left-color: var(--status-rejected); }

.profile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.profile-card-name {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text);
}

.profile-card-id {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.profile-card-parents {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.profile-card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-badge.status-New { background: #ECEFF1; color: #455A64; }
.status-badge.status-Contacted { background: #E3F2FD; color: #1565C0; }
.status-badge.status-Conversation { background: #FFF8E1; color: #F57F17; }
.status-badge.status-Waiting { background: #FFF3E0; color: #E65100; }
.status-badge.status-Shortlisted { background: #E8F5E9; color: #2E7D32; }
.status-badge.status-Rejected { background: #FFEBEE; color: #C62828; }

.decision-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.decision-badge.decision-Yes { background: #E8F5E9; color: #2E7D32; }
.decision-badge.decision-No { background: #FFEBEE; color: #C62828; }
.decision-badge.decision-Not\ Decided { background: #F5F5F5; color: #757575; }

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

.card-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
}

.card-action-btn:active {
    transform: scale(0.96);
}

.btn-view {
    background: #F3E5F5;
    color: #7B1FA2;
}

.btn-call {
    background: #E8F5E9;
    color: #2E7D32;
}

/* ========================================
   Profile Detail
   ======================================== */
.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    min-height: var(--tap-size);
}

.back-btn:active {
    background: rgba(181, 69, 27, 0.1);
}

.profile-detail {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--shadow);
}

.detail-name {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.detail-id {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.detail-field {
    margin-bottom: 16px;
}

.detail-field-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.detail-field-value {
    font-size: var(--font-size-lg);
    color: var(--text);
}

.detail-field-value.phone {
    color: var(--info);
    font-weight: 600;
}

.detail-field-value.notes {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.5;
}

.detail-status-section {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.status-control, .decision-control {
    flex: 1;
    min-width: 140px;
}

.status-control label, .decision-control label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.status-control select, .decision-control select {
    width: 100%;
    padding: 12px 14px;
    font-size: var(--font-size-base);
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.detail-actions .btn {
    flex: 1;
    min-width: 100px;
}

.btn-call-large {
    background: var(--success);
    color: white;
    font-size: var(--font-size-lg);
}

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

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

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: var(--font-size-xl);
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: var(--font-size-base);
}

/* ========================================
   Bottom Navigation
   ======================================== */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 56px;
    color: var(--text-secondary);
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 12px;
    font-weight: 600;
}

/* ========================================
   Modals
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: var(--font-size-xl);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    color: var(--text-secondary);
}

.modal-close:active {
    background: rgba(0,0,0,0.1);
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* ========================================
   Settings
   ======================================== */
.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.settings-label {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
}

.settings-value {
    font-weight: 600;
    font-size: var(--font-size-base);
}

.settings-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: 20px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ========================================
   Messages
   ======================================== */
.error-message {
    background: #FFEBEE;
    color: #C62828;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    margin-bottom: 16px;
}

.success-message {
    background: #E8F5E9;
    color: #2E7D32;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    margin-bottom: 16px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(100px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: var(--font-size-base);
    font-weight: 500;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 48px);
    text-align: center;
}

/* ========================================
   Responsive - Tablet/Desktop
   ======================================== */
@media (min-width: 768px) {
    .filter-cards {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .main-content {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .profile-detail {
        max-width: 600px;
    }
}

/* ========================================
   Loading State
   ======================================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Profile form */
.profile-form {
    max-width: 500px;
}

.profile-form .btn {
    margin-top: 8px;
}

/* ========================================
   PIN Screen
   ======================================== */
.pin-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    padding-top: calc(40px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
}

.pin-logo {
    text-align: center;
    margin-bottom: 32px;
}

.pin-logo .logo-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.pin-logo h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
}

.pin-step {
    width: 100%;
    max-width: 360px;
}

.pin-instruction {
    text-align: center;
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.pin-step input[type="password"],
.pin-step input[type="text"] {
    text-align: center;
    font-size: 24px;
    letter-spacing: 8px;
    font-weight: 700;
}

.btn-link {
    display: block;
    text-align: center;
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-size-base);
    font-weight: 600;
    padding: 12px;
    margin-top: 16px;
    cursor: pointer;
    width: 100%;
}

.btn-link:active {
    opacity: 0.7;
}

.recovery-box {
    background: #FFF3E0;
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}

.recovery-code {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--text);
    margin: 16px 0;
    font-family: monospace;
}

.recovery-warning {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========================================
   Settings Panel
   ======================================== */
.settings-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.settings-section .btn {
    margin-top: 8px;
}

.settings-section .btn-block {
    margin-top: 8px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
    min-height: 36px;
}

/* Welcome bar */
.welcome-bar {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding: 0 4px;
}
