:root {
    --bg-color: #f9f9f9;
    --text-color: #333;
    --primary-color: #0066cc;
    --success-color: #25d366; /* WhatsApp Green */
    --secondary-color: #6c757d;
    --border-color: #ddd;
    --box-bg: #fff;
    --error-color: #dc3545;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.view {
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

h2 {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 15px;
    color: #444;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 15px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.preview-box {
    background-color: var(--box-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    white-space: pre-wrap;
    min-height: 150px;
    font-size: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    margin-bottom: 15px;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

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

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

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

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: #f0f7ff;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

@media (min-width: 450px) {
    .action-buttons {
        flex-direction: row;
    }
    .action-buttons .btn {
        margin-bottom: 0;
        flex: 1;
    }
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.error-msg {
    color: var(--error-color);
    margin-bottom: 15px;
    font-weight: bold;
}

/* For slightly larger screens, place buttons side by side if preferred */
@media (min-width: 450px) {
    .button-group {
        flex-direction: row;
    }
    .button-group .btn {
        margin-bottom: 0;
        flex: 1;
    }
}

/* --- TABS SWITCHER --- */
.view-tabs {
    display: flex;
    background-color: #e2e8f0;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 16px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background-color: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background-color: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* --- TABULAR LIST STYLES --- */
.badge-count {
    display: inline-flex;
    align-items: center;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    background-color: var(--box-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

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

.items-table th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    border-bottom: 2px solid #e2e8f0;
}

.items-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
    color: #1e293b;
    vertical-align: middle;
}

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

.items-table tbody tr:hover td {
    background-color: #f8fafc;
}

.col-num {
    width: 40px;
    text-align: center;
    color: #94a3b8;
    font-weight: 600;
}

.col-item {
    font-weight: 600;
}

.item-main {
    font-weight: 600;
    color: #0f172a;
}

.item-raw {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: normal;
    margin-top: 2px;
}

.col-qty, .col-unit {
    text-align: center;
    width: 75px;
}

.qty-badge {
    display: inline-block;
    background-color: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.unit-badge {
    display: inline-block;
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.no-items-row {
    text-align: center;
    color: #64748b;
    padding: 24px 16px !important;
}

/* Accordion for original message */
.raw-preview-accordion {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    background-color: #ffffff;
    overflow: hidden;
}

.raw-preview-accordion summary {
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: #f8fafc;
    cursor: pointer;
    color: #475569;
    user-select: none;
}

.raw-preview-inner {
    padding: 12px 14px;
    font-size: 0.9rem;
    color: #334155;
    white-space: pre-wrap;
    border-top: 1px solid #e2e8f0;
}

.convert-sub-btn {
    margin-top: -5px;
    margin-bottom: 20px;
}

/* Accordion for WhatsApp message preview */
.whatsapp-preview-accordion {
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    margin-bottom: 20px;
    background-color: #f1f8e9;
    overflow: hidden;
}

.whatsapp-preview-accordion summary {
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: #e8f5e9;
    cursor: pointer;
    color: #2e7d32;
    user-select: none;
}

.whatsapp-preview-inner {
    padding: 14px 16px;
    font-size: 0.92rem;
    color: #1b5e20;
    white-space: pre-wrap;
    background-color: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    border-top: 1px solid #c8e6c9;
    line-height: 1.6;
}

.whatsapp-preview-actions {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    background-color: #f1f8e9;
    border-top: 1px solid #e0f2f1;
}

.btn-copy-preview {
    background-color: #ffffff;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy-preview:hover {
    background-color: #e8f5e9;
    border-color: #81c784;
}

.btn-copy-preview.copied {
    background-color: #2e7d32;
    color: #ffffff;
    border-color: #2e7d32;
}

.parsing-indicator {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Voice UI Styles */
.voice-section {
    margin-bottom: 20px;
}

.divider {
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    line-height: 0.1em;
    margin: 20px 0;
}

.divider span {
    background: var(--bg-color);
    padding: 0 10px;
    color: var(--secondary-color);
    font-weight: bold;
}

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

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

.recording-text {
    color: var(--error-color);
    font-weight: bold;
    margin-bottom: 15px;
}

.pulse-text {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Draft persistence & UI enhancements */
.input-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.input-header-row h2 {
    margin: 0;
}

.clear-draft-btn {
    background: none;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.clear-draft-btn:hover {
    color: var(--error-color);
    border-color: #fca5a5;
    background-color: #fef2f2;
}

.sent-banner {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.sent-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-new-order {
    background-color: #059669;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-new-order:hover {
    background-color: #047857;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
