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

:root {
    --bg-color: #f1f5f9; 
    --card-bg: #ffffff; 
    --text-main: #0f172a; 
    --text-muted: #64748b;
    --primary: #1d4ed8; 
    --primary-hover: #1e40af; 
    --danger: #ef4444; 
    --border: #e2e8f0; 
    --input-bg: #f8fafc;
    --text-color: #0f172a;
    --radius: 16px;
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { overflow-x: hidden; width: 100%; max-width: 100vw; 
    font-family: 'Inter', sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    -webkit-font-smoothing: antialiased; 
}

/* Recording Pulse Animation */
.pulse-dot {
    width: 16px;
    height: 16px;
    background-color: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.app-container { max-width: 500px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-color); box-shadow: 0 0 20px rgba(0,0,0,0.05); }

/* Header */
header { background: var(--card-bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 9990; width: 100%; }
.header-inner { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 1200px; margin: 0 auto; padding: 15px 20px; }
.logo h1 { font-size: 20px; font-weight: 800; background: var(--primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -0.5px; margin: 0; }
.header-right { display: flex; align-items: center; gap: 8px; }
.credits { background: #eff6ff; color: #1e40af; padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 14px; border: 1px solid #bfdbfe; }
.credits.infinite { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.credits.premium-badge { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.credits.zero { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Main Content */
main { flex: 1; padding: 20px; padding-bottom: 80px; display: flex; flex-direction: column; }
section { display: none; flex-direction: column; flex: 1; }
section.active-section { display: flex; animation: fadeIn 0.4s ease; }
.hidden-section { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    background: #ffffff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav .nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.bottom-nav .nav-item.active, .bottom-nav .nav-item:hover {
    color: var(--primary);
}

/* Cards & Forms */
.hidden { display: none !important; }
.card { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--glass-shadow); border: 1px solid var(--border); margin-bottom: 20px; }
h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
p.subtitle { color: var(--text-muted); font-size: 15px; margin-bottom: 25px; line-height: 1.5; }
.form-group { margin-bottom: 24px; text-align: left; }
label { display: block; font-size: 14px; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
input, textarea, select { 
    width: 100%; padding: 14px 16px; background: #f8fafc; border: 2px solid var(--border); 
    border-radius: 12px; color: var(--text-main); font-family: 'Inter', sans-serif; font-size: 16px; 
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
}
input::placeholder, textarea::placeholder { color: #94a3b8; font-weight: 500; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); background: #ffffff; box-shadow: 0 4px 12px rgba(29, 78, 216, 0.1); }

/* Buttons */
button { font-family: 'Inter', sans-serif; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.primary-btn { 
    width: 100%; padding: 16px; 
    background: var(--primary); 
    color: white; border: none; border-radius: 12px; font-size: 16px; margin-bottom: 12px; 
    box-shadow: 0 4px 6px -1px rgba(29, 78, 216, 0.2);
}
.primary-btn:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: translateY(0); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.secondary-btn { 
    width: 100%; padding: 16px; 
    background: #ffffff; 
    color: var(--text-main); border: 1px solid var(--border); 
    border-radius: 12px; font-size: 16px; 
}
.secondary-btn:hover:not(:disabled) { background: #f1f5f9; }
.text-btn { background: none; border: none; color: var(--text-muted); font-size: 14px; }
.text-btn:hover { color: var(--text-main); text-decoration: underline; }

.primary-btn-small {
    background: var(--primary);
    color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
    padding: 8px 16px; box-shadow: 0 2px 4px rgba(29, 78, 216, 0.2);
}
.primary-btn-small:hover { background: var(--primary-hover); }

.icon-btn {
    background: #ffffff; border: 1px solid var(--border);
    border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--text-muted); transition: all 0.2s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text-main); }

/* Record Button (Massive Centralized UI) */
.record-hero { text-align: center; margin-top: 40px; margin-bottom: 20px; }
.record-container-large { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    flex: 1; padding: 20px; min-height: 50vh;
}
.massive-record-btn {
    width: 220px; height: 220px; border-radius: 50%;
    background: var(--primary);
    border: none; box-shadow: 0 10px 25px rgba(29, 78, 216, 0.3);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; margin-bottom: 30px;
}
.massive-record-btn:hover { transform: scale(1.02); background: var(--primary-hover); box-shadow: 0 15px 35px rgba(29, 78, 216, 0.4); }
.massive-record-btn:active { transform: scale(0.98); }
.massive-record-btn.recording {
    background: var(--danger);
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0.15);
    animation: massive-pulse 1.5s infinite;
}
.mic-icon-large { font-size: 80px; color: white; }
.record-status-large { font-weight: 600; color: var(--text-muted); font-size: 20px; letter-spacing: 0.5px; }
@keyframes massive-pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); } 70% { box-shadow: 0 0 0 40px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* Line Items */
.line-items-header { display: flex; justify-content: space-between; align-items: center; margin-top: 25px; margin-bottom: 15px; border-top: 1px solid var(--border); padding-top: 25px; }
.line-items-header h3 { font-size: 18px; margin: 0; color: var(--text-main); }
.line-item-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.line-item-row-controls { display: flex; gap: 8px; align-items: center; }
.desc-input { flex: 1; min-width: 0; margin-bottom: 0; border: 1px solid transparent; background: transparent; padding: 4px; font-size: 14px; font-weight: 600; color: var(--text-main); outline: none; width: 100%; resize: vertical; line-height: 1.4; border-radius: 6px; }
.desc-input:hover { border-color: #f1f5f9; }
.desc-input:focus { border-color: var(--primary); background: #ffffff; }
.price-input { width: 140px; flex-shrink: 0; text-align: left; margin-bottom: 0; padding-right: 12px; border: 1px solid #e2e8f0; border-radius: 8px; padding-top: 8px; padding-bottom: 8px; font-weight: 600; }
.price-input:focus { border-color: var(--primary); outline: none; }
.price-input::-webkit-outer-spin-button, .price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.price-input[type=number] { -moz-appearance: textfield; }
.remove-btn { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: #ef4444; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.remove-btn:hover { background: #fee2e2; }
.total-row { display: flex; justify-content: space-between; font-weight: 800; font-size: 20px; margin-top: 25px; padding-top: 20px; border-top: 2px dashed var(--border); color: var(--primary); }

/* Spinners & Previews */
.spinner { width: 46px; height: 46px; border: 4px solid #e2e8f0; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 60px auto 25px; }
@keyframes spin { to { transform: rotate(360deg); } }
#processing-section, #result-section { align-items: center; text-align: center; }
.pdf-preview { font-size: 90px; margin: 40px 0; }
.action-buttons { width: 100%; display: flex; flex-direction: column; gap: 12px; }

/* Toast Notifications */
.toast-container { position: fixed; top: 20px; right: 20px; left: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; align-items: center; }
@media (min-width: 500px) { .toast-container { left: auto; right: 20px; align-items: flex-end; } }
.toast { 
    background: #ffffff; 
    color: var(--text-main); padding: 16px 24px; border-radius: 12px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); border: 1px solid var(--border); 
    border-left: 5px solid var(--primary); display: flex; align-items: center; 
    min-width: 300px; transform: translateY(-120%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); 
    pointer-events: auto; font-size: 15px; font-weight: 500; 
}
.toast.show { transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: #10b981; }

button.primary-btn.loading { position: relative; color: transparent !important; }
button.primary-btn.loading::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 20px; height: 20px; margin-left: -10px; margin-top: -10px;
    border: 2px solid rgba(255,255,255,0.4); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s infinite linear;
}

/* Modal specific styles */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content {
    background: #ffffff;
    border: 1px solid var(--border); border-radius: 16px;
    padding: 30px; width: 90%; max-width: 400px;
    transform: scale(0.95); transition: transform 0.2s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-content h3 { color: var(--text-main); margin-bottom: 15px; font-size: 20px; }
.modal-content p { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }

/* History Cards */
.history-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.history-title { font-weight: 600; font-size: 16px; color: var(--text-main); margin-bottom: 4px; }
.history-date { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.history-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* Dashboard Status Selector */
.status-selector {
    padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
    font-size: 13px; font-weight: 600; outline: none; flex: 1; background: #ffffff; color: var(--text-main);
}
.status-sent { background-color: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.status-accepted { background-color: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.status-declined { background-color: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* Settings Header Tabs */
.settings-tabs { display: flex; gap: 10px; margin-bottom: 20px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.settings-tab { flex: 1; padding: 10px; text-align: center; background: transparent; color: var(--text-muted); border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.settings-tab.active { background: #ffffff; color: var(--text-main); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Billing Table */
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; }
td { color: var(--text-main); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge.paid { background: #ecfdf5; color: #047857; }

/* Mobile adjustments */
@media (max-width: 600px) {
    header .header-inner { padding: 12px; }
    header h1 { display: none; } /* Hide 'VoiceBid' text on small screens, keep logo */
    .user-greeting { display: none !important; }
    .header-right { gap: 5px; }
    .credits { font-size: 12px; padding: 4px 8px; }
    .primary-btn-small { font-size: 12px; padding: 6px 10px; margin-left: 5px; }
    .icon-btn { width: 34px; height: 34px; font-size: 16px; margin-left: 3px; }
    
    main { padding: 15px 10px; }
    .auth-box { padding: 25px 15px; }
    .card { padding: 16px; border-radius: 12px; }
    .massive-record-btn { width: 180px; height: 180px; }
    .mic-icon-large { font-size: 60px; }
    
    .auth-box > div[style*="display: flex"] { flex-direction: column; }
}

/* Ultra-narrow devices */
@media (max-width: 395px) {
    main { padding: 10px 8px; }
    .header-inner { padding: 10px 8px; }
    .header-right { gap: 2px; }
    .credits { font-size: 11px; padding: 4px 6px; }
    .primary-btn-small { font-size: 11px; padding: 5px 8px; margin-left: 2px; }
    .icon-btn { width: 30px; height: 30px; font-size: 14px; margin-left: 1px; }
    .auth-box { padding: 20px 10px; }
    input, textarea, select { padding: 12px 14px; font-size: 16px; }
}

/* AI Price Confirmation Feature */
.estimated-price {
    border: 2px dashed #f59e0b !important;
    background-color: #fffbeb !important;
    color: #92400e !important;
    transition: all 0.2s ease;
}

.estimated-price.unconfirmed {
    animation: pulse-amber 2s infinite;
}

.estimated-price:not(.unconfirmed) {
    border: 2px solid #10b981 !important;
    background-color: #ecfdf5 !important;
    color: #065f46 !important;
}

@keyframes pulse-amber {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2); }
    70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.auth-box { background: var(--card-bg); border-radius: var(--radius); padding: 30px; 
box-shadow: var(--glass-shadow); border: 1px solid var(--border); margin: 0 auto; max-width: 400px; width: 100%; 
text-align: center; }

#auth-section { 
    padding: 0; 
    min-height: calc(100vh - 80px);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
}

.auth-tabs { display: flex; gap: 10px; margin-bottom: 20px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.auth-tab { flex: 1; padding: 10px; text-align: center; background: transparent; color: var(--text-muted); border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; }
.auth-tab.active { background: #ffffff; color: var(--text-main); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.pwd-strength-container { height: 4px; display: flex; gap: 4px; margin-top: -10px; margin-bottom: 10px; }
.pwd-strength-bar { flex: 1; height: 100%; border-radius: 2px; background: var(--border); transition: 0.3s; }
.pwd-strength-bar.weak { background: #ef4444; }
.pwd-strength-bar.fair { background: #f59e0b; }
.pwd-strength-bar.good { background: #10b981; }
.pwd-strength-bar.strong { background: #059669; }


/* Mobile Responsiveness Restored */
@media (max-width: 600px) {
    .header-inner { padding: 12px; }
    .logo h1 { display: none; } /* Hide 'VoiceBid' text on small screens, keep logo */
    .user-greeting { display: none !important; }
    .header-right { gap: 5px; }
    .credits { font-size: 12px; padding: 4px 8px; }
    .primary-btn-small { font-size: 12px; padding: 6px 10px; margin-left: 5px; }
    .icon-btn { width: 34px; height: 34px; font-size: 16px; margin-left: 3px; }
    
    .auth-box > div[style*="display: flex"] { flex-direction: column; }
    #pricing-modal .auth-box > div[style*="display: flex"] { flex-direction: column; }
}

@media (min-width: 500px) { .toast-container { left: auto; right: 20px; align-items: flex-end; } }

@media (max-width: 450px) {
    .massive-record-btn { width: 180px; height: 180px; }
    .mic-icon-large { font-size: 60px; }
}

@media (max-width: 395px) {
    .header-inner { padding: 10px; }
    .header-right { gap: 2px; }
    .credits { font-size: 11px; padding: 4px 6px; }
    .primary-btn-small { font-size: 11px; padding: 5px 8px; margin-left: 2px; }
    .icon-btn { width: 30px; height: 30px; font-size: 14px; margin-left: 1px; }
}
