/* ================= VARIABLES & RESET ================= */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --danger: #ef4444;
    --success: #10b981;
    --bg-light: #f8fafc;
    --bg-dark: #0f172a;
    --card-light: rgba(255, 255, 255, 0.7);
    --card-dark: rgba(30, 41, 59, 0.7);
    --text-light: #1e293b;
    --text-dark: #f1f5f9;
    --border-light: rgba(255, 255, 255, 0.5);
    --border-dark: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

body {
    background-color: var(--bg-light);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

/* ================= UTILITIES ================= */
.hidden { display: none !important; }
.glass {
    background: var(--card-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
}
body.dark-mode .glass {
    background: var(--card-dark);
    border: 1px solid var(--border-dark);
}

/* ================= AUTH VIEW ================= */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; }

#auth-view {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container { width: 100%; max-width: 420px; }

.logo-area {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}
.logo-area i { font-size: 3rem; margin-bottom: 1rem; }
.logo-area h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }

.auth-card {
    padding: 2rem;
    border-radius: 20px;
    width: 100%;
}

.tabs {
    display: flex;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 4px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    color: inherit;
    opacity: 0.6;
}
.tab-btn.active {
    background: white;
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
body.dark-mode .tab-btn.active { background: #334155; color: white; }

.input-group {
    position: relative;
    margin-bottom: 1rem;
}
.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.input-group input {
    width: 100%;
    padding: 12px 12px 12px 45px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    background: transparent;
    color: inherit;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.btn-primary:hover { background: var(--primary-dark); }

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: #94a3b8;
    font-size: 0.85rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
    margin: 0 10px;
}

.btn-google {
    width: 100%;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    color: #1e293b;
}
.btn-google img { width: 20px; }

/* ================= APP VIEW ================= */
#app-view { flex-direction: column; }

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; }
.nav-brand i { color: var(--primary); font-size: 1.5rem; }

.nav-actions { display: flex; align-items: center; gap: 15px; }

.usage-badge {
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; cursor: pointer; border: 2px solid var(--primary); }

.main-container { padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; flex: 1; }

.controls { margin-bottom: 2rem; }
.search-box {
    position: relative;
    max-width: 400px;
}
.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.search-box input {
    width: 100%;
    padding: 12px 12px 12px 45px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: var(--card-light);
    color: inherit;
    font-size: 1rem;
}
body.dark-mode .search-box input {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

/* Notes Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.note-card {
    padding: 1.5rem;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}
.note-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}
.note-card h3 { margin-bottom: 0.5rem; font-size: 1.1rem; }
.note-card p { color: #64748b; font-size: 0.9rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card .date { font-size: 0.75rem; color: #94a3b8; margin-top: 1rem; display: block; }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

/* Floating Action Button */
.fab-record {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fab-record:hover { transform: scale(1.1); }
.fab-record:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; box-shadow: none; }

/* Overlays */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.recording-modal {
    width: 100%;
    max-width: 500px;
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
}

.recording-animation {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.recording-animation i { font-size: 2.5rem; color: var(--danger); z-index: 2; }
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}
.pulse-ring:nth-child(2) { animation-delay: 1s; }

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.live-text {
    min-height: 60px;
    margin: 1.5rem 0;
    font-size: 1.2rem;
    color: var(--text-light);
    font-weight: 500;
}
body.dark-mode .live-text { color: var(--text-dark); }

.btn-danger {
    padding: 12px 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
}

.processing-modal {
    text-align: center;
    padding: 3rem;
    border-radius: 24px;
}
.spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-content {
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 2rem;
    position: relative;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header input {
    font-size: 1.5rem;
    font-weight: 700;
    border: none;
    background: transparent;
    color: inherit;
    width: 100%;
    outline: none;
}
.modal-body { margin-bottom: 1.5rem; }
.section { margin-bottom: 1.5rem; }
.section h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 8px; }
.content-editable {
    padding: 1rem;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    min-height: 60px;
    outline: none;
    border: 1px solid transparent;
}
.content-editable:focus { border-color: var(--primary); background: transparent; }
.transcript-box {
    background: rgba(0,0,0,0.05);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #64748b;
    max-height: 200px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}
body.dark-mode .modal-footer { border-color: #334155; }

.btn-secondary {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    color: inherit;
    margin-right: 10px;
}
.btn-text-danger { color: var(--danger); background: none; border: none; cursor: pointer; font-weight: 500; }
.action-group { display: flex; }

/* Upgrade Modal Specifics */
.upgrade-card { text-align: center; max-width: 400px; }
.upgrade-header i { font-size: 3rem; color: #f59e0b; margin-bottom: 1rem; }
.features-list { list-style: none; margin: 2rem 0; text-align: left; }
.features-list li { padding: 10px 0; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 10px; }
.features-list i { color: var(--success); }
.btn-premium {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 1rem;
}
.btn-text { background: none; border: none; color: #64748b; cursor: pointer; }

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container { padding: 1rem; }
    .notes-grid { grid-template-columns: 1fr; }
    .fab-record { bottom: 1.5rem; right: 1.5rem; }
    .modal-content { padding: 1.5rem; }
}
