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

:root {
    --bg-primary: #0b0d0e;
    --bg-secondary: #14171a;
    --bg-card: rgba(22, 27, 30, 0.75);
    --border-glass: rgba(255, 255, 255, 0.06);
    
    --accent-emerald: #10b981;
    --accent-emerald-hover: #059669;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    
    --accent-gold: #f59e0b;
    --accent-gold-glow: rgba(245, 158, 11, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-danger: #ef4444;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 480px; /* Strict Mobile-First Constraint */
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 40px;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-gold));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #000;
    box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.brand h1 {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand span {
    font-size: 11px;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: block;
}

/* Badge Mode (Live / Demo) */
.mode-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.mode-badge.demo {
    background-color: var(--accent-gold-glow);
    color: var(--accent-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.mode-badge.live {
    background-color: var(--accent-emerald-glow);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.1);
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-title i {
    color: var(--accent-emerald);
}

/* Inputs & Form styling */
.form-group {
    margin-bottom: 15px;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type="text"], select, textarea {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition-smooth);
    outline: none;
}

input[type="text"]:focus, select:focus, textarea:focus {
    border-color: var(--accent-emerald);
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 10px var(--accent-emerald-glow);
}

/* Tag Container for Species Suggestions */
.species-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tag {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.tag:hover, .tag.active {
    background-color: var(--accent-emerald-glow);
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
}

/* Media Dashboard & Upload Zones */
.media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.upload-zone {
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px dashed var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 16px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-zone:hover {
    border-color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.02);
}

.upload-zone i {
    font-size: 20px;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.upload-zone:hover i {
    color: var(--accent-emerald);
    transform: translateY(-2px);
}

.upload-zone span {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Dragover animation state */
.upload-zone.dragover {
    border-color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.05);
    transform: scale(1.02);
}

/* Audio Recording Section */
.audio-recorder-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.record-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background-color: var(--text-danger);
    border: 4px solid rgba(239, 68, 68, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.record-btn.recording {
    background-color: #1e293b;
    border-color: var(--text-danger);
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.recording-status {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.recording-status span.dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-danger);
    border-radius: 50%;
    display: inline-block;
}

.recording-status.active span.dot {
    animation: flash 1s infinite alternate;
}

@keyframes flash {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

/* File list */
.file-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    transition: var(--transition-smooth);
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80%;
}

.file-item-info i {
    color: var(--accent-emerald);
}

.file-item-size {
    font-size: 10px;
    color: var(--text-muted);
}

.file-item-remove {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
}

.file-item-remove:hover {
    color: var(--text-danger);
}

/* Master Action Button */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-emerald-hover));
    color: #0b0d0e;
    font-weight: 700;
    font-size: 16px;
    padding: 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 20px var(--accent-emerald-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #1e293b;
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Secondary Actions */
.btn-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Result Editor Tabs */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 2px solid transparent;
    font-family: inherit;
    text-align: center;
}

.tab-btn.active {
    color: var(--accent-emerald);
    border-bottom-color: var(--accent-emerald);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Rich Text Editor Simulation */
.editor-area {
    min-height: 250px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
}

.editor-area:focus {
    border-color: var(--accent-emerald);
}

/* Floating Chat Interface Drawer */
.chat-drawer {
    display: flex;
    flex-direction: column;
    height: 350px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    margin-top: 15px;
}

.chat-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-glass);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.5;
}

.chat-bubble.user {
    align-self: flex-end;
    background-color: var(--accent-emerald-glow);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
    border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-input-row {
    display: flex;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-glass);
    gap: 6px;
}

.chat-input-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}

.chat-input-row input:focus {
    border-color: var(--accent-emerald);
}

.chat-send-btn {
    background: var(--accent-emerald);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b0d0e;
    transition: var(--transition-smooth);
}

.chat-send-btn:hover {
    background: var(--accent-emerald-hover);
}

/* Fullscreen Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 13, 14, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loader-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(16, 185, 129, 0.1);
    border-top-color: var(--accent-emerald);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loader-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.loader-subtext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(20, 23, 26, 0.9);
    border: 1px solid var(--accent-emerald);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 13px;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    white-space: nowrap;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
}

/* Toggle API Configurations for testing */
.config-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-premium);
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    padding: 20px;
}

.config-modal.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: all;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}
