/* assets/style.css */
/* Mobile-first, premium design system for the EMA Sales Product Survey system. */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --color-primary:       #2a9d8f;   /* Teal - main brand color */
    --color-primary-dark:  #1f7a6e;   /* Dark teal for active/hover */
    --color-danger:        #e76f51;   /* Red-orange for NO button */
    --color-success:       #2a9d8f;   /* Teal for YES button */
    --color-bg:            #f4f6f8;   /* Soft, modern background */
    --color-card:          #ffffff;   /* Pure white cards */
    --color-text:          #2d3748;   /* Sleek slate text */
    --color-muted:         #718096;   /* Cool grey for subtext */
    --color-border:        #e2e8f0;   /* Light border */
    --radius:              14px;      /* Premium smooth corners */
    --radius-sm:           8px;
    --shadow:              0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg:           0 20px 25px -5px rgba(42, 157, 143, 0.1), 0 10px 10px -5px rgba(42, 157, 143, 0.04);
    --transition:          all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container (centered on desktop, full width on mobile) */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 90px; /* Space for sticky footer bar */
}

/* Top Header Bar */
.header-bar {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

.header-bar .sp-name-tag {
    font-size: 0.85rem;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.18);
    padding: 5px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress Container */
.progress-container {
    background-color: var(--color-card);
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.01);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-muted);
}

.progress-header .highlight {
    color: var(--color-primary);
    font-weight: 700;
}

.progress-track {
    height: 8px;
    background-color: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #4ecdc4);
    border-radius: 4px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cards & Layout */
.content-area {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background-color: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: var(--transition);
}

.card.tappable {
    cursor: pointer;
}

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

.card.selected {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    background-color: rgba(42, 157, 143, 0.02);
}

/* Home / Selection Page Specific */
.sp-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.sp-card {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.sp-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
}

.sp-card-arrow {
    color: var(--color-muted);
    font-size: 1.2rem;
    transition: var(--transition);
}

.sp-card.selected .sp-card-arrow {
    color: var(--color-primary);
    transform: translateX(4px);
}

/* Customer Card */
.customer-card {
    background: linear-gradient(to bottom right, #ffffff, #fdfdfd);
    position: relative;
    overflow: hidden;
}

.customer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background-color: var(--color-primary);
}

.customer-store-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.customer-meta-row {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.customer-meta-label {
    font-weight: 600;
    color: var(--color-text);
    min-width: 80px;
    flex-shrink: 0;
}

.customer-meta-value {
    word-break: break-word;
}

/* Product Survey Form Row */
.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 6px;
}

.survey-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

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

.product-label {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-text);
    padding-right: 12px;
}

/* Radio Toggle Pill Buttons */
.toggle-wrapper {
    display: inline-flex;
    gap: 8px;
}

.toggle-pill {
    position: relative;
    display: block;
    width: 70px;
    height: 44px; /* Minimum tap target */
}

.toggle-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: 22px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.toggle-pill.yes input:checked + .toggle-label {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: white;
    box-shadow: 0 4px 10px rgba(42, 157, 143, 0.3);
}

.toggle-pill.no input:checked + .toggle-label {
    background-color: var(--color-danger);
    border-color: var(--color-danger);
    color: white;
    box-shadow: 0 4px 10px rgba(231, 111, 81, 0.3);
}

/* Sticky Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background-color: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    z-index: 100;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); /* Safe padding for newer iPhones */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 12px 24px;
    min-height: 48px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(42, 157, 143, 0.2);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(42, 157, 143, 0.1);
}

.btn-secondary {
    background-color: #edf2f7;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:active:not(:disabled) {
    background-color: #e2e8f0;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.bottom-nav .btn {
    flex: 1;
}

.bottom-nav .btn-summary {
    flex: 0 0 54px;
    padding: 0;
    border-radius: 50%;
    background-color: #edf2f7;
    color: #4a5568;
    font-size: 1.25rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: #2d3748;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    text-align: center;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

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

/* Summary / List Page */
.summary-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.summary-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.btn-back-survey {
    font-size: 0.85rem;
    padding: 6px 12px;
    min-height: auto;
}

.customer-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--color-card);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    margin-bottom: 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.customer-list-item:active {
    transform: scale(0.99);
}

.customer-info-block {
    flex: 1;
    padding-right: 12px;
}

.customer-list-name {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 4px;
    color: var(--color-text);
}

.customer-list-market {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.done {
    background-color: rgba(42, 157, 143, 0.12);
    color: var(--color-primary-dark);
}

.status-badge.pending {
    background-color: #edf2f7;
    color: #718096;
}

/* Completion Page */
.complete-card {
    text-align: center;
    padding: 40px 20px;
    margin-top: 40px;
}

.checkmark-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(42, 157, 143, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    color: var(--color-primary);
}

.complete-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.complete-subtext {
    color: var(--color-muted);
    margin-bottom: 32px;
    font-size: 1rem;
}

.complete-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Control Panel / Admin Dashboard */
.admin-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.admin-meta {
    font-size: 0.85rem;
    color: var(--color-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 4px;
}

.admin-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* Admin Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    background-color: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    margin-bottom: 30px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th, .admin-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
}

.admin-table th {
    background-color: #f7fafc;
    font-weight: 700;
    color: var(--color-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
}

.admin-table th:hover {
    color: var(--color-text);
}

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

.admin-table tr.total-row td {
    font-weight: 700;
    background-color: #f7fafc;
    border-top: 2px solid var(--color-border);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

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