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

/* =========================================
   CSS VARIABLES - NuiTruc Brand System
   ========================================= */
:root {
    --bg-primary: #151f2e;
    --bg-secondary: #1a2639;
    --bg-card: #1e2d42;
    --bg-card-hover: #243451;
    --bg-elevated: #1a2639;

    --accent: #00E5C8;
    --accent-dim: rgba(0, 229, 200, 0.12);
    --accent-border: rgba(0, 229, 200, 0.3);
    --accent-glow: 0 0 24px rgba(0, 229, 200, 0.25);

    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --text-muted: #555555;

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --danger: #ff4d4d;
    --danger-dim: rgba(255, 77, 77, 0.1);
    --success: #00E5C8;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.4);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.6);

    --font-display: 'Syne', sans-serif;
    --font-body: 'Inter', sans-serif;

    --transition: 0.2s ease;
}

/* =========================================
   RESET & BASE
   ========================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   NAVBAR
   ========================================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.nav-logo {
    height: 32px;
    width: auto;
}

.nav-brand h2 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.nav-brand h2 span {
    color: var(--accent);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.nav-menu>li>a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.nav-menu>li>a:hover,
.nav-menu>li>a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-menu>li>a.active {
    color: var(--accent);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle::after {
    content: '▾';
    font-size: 11px;
    margin-left: 2px;
    opacity: 0.5;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-elevated);
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
}

.nav-dropdown-menu a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-dropdown-menu a.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.nav-dropdown-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Logout */
.nav-menu .logout {
    color: var(--text-muted) !important;
}

.nav-menu .logout:hover {
    color: var(--danger) !important;
    background: var(--danger-dim) !important;
}

/* =========================================
   CONTAINER
   ========================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* =========================================
   PAGE HEADER
   ========================================= */
.page-header,
.dashboard-header {
    margin-bottom: 40px;
}

.page-header h1,
.dashboard-header h1 {
    font-family: var(--font-display);
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.page-header p,
.dashboard-header p {
    font-size: 15px;
    color: var(--text-secondary);
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
    font-weight: 700;
}

.btn-primary:hover {
    background: #00f5d6;
    box-shadow: var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-hover);
}

.btn-large {
    padding: 13px 24px;
    font-size: 15px;
    width: 100%;
}

/* =========================================
   CARDS
   ========================================= */
.form-card,
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-card);
}

.form-card h3,
.result-card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* =========================================
   DASHBOARD GRID
   ========================================= */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    text-align: center;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.feature-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-3px);
    box-shadow: var(--accent-glow), var(--shadow-card);
}

.feature-icon {
    font-size: 40px;
    margin-bottom: 16px;
    display: block;
}

.feature-card h3 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

.feature-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* =========================================
   UPLOAD AREA
   ========================================= */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* =========================================
   FILE PREVIEW
   ========================================= */
.file-preview {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.file-preview.visible {
    display: block;
}

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

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-clear:hover {
    background: var(--danger-dim);
    color: var(--danger);
}

.preview-image {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: block;
}

.audio-player {
    width: 100%;
    margin: 8px 0;
    border-radius: var(--radius-sm);
}

audio::-webkit-media-controls-panel {
    background: var(--bg-elevated);
}

.file-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* =========================================
   OCR / STT LAYOUT
   ========================================= */
.ocr-container,
.stt-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {

    .ocr-container,
    .stt-container {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   TTS LAYOUT
   ========================================= */
.tts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .tts-container {
        grid-template-columns: 1fr;
    }
}

.tts-textarea {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    resize: vertical;
    min-height: 140px;
    transition: border-color var(--transition);
    margin-bottom: 20px;
}

.tts-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.tts-textarea::placeholder {
    color: var(--text-muted);
}

/* =========================================
   FORM ELEMENTS
   ========================================= */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.voice-select,
select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.voice-select:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

/* =========================================
   RECORD SECTION
   ========================================= */
.record-section {
    margin: 20px 0;
}

.record-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.record-divider::before,
.record-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.record-divider span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.recording-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 77, 77, 0.08);
    border: 1px solid rgba(255, 77, 77, 0.2);
    border-radius: var(--radius-sm);
    margin-top: 10px;
    font-size: 13px;
    color: var(--danger);
}

.recording-indicator.active {
    display: flex;
}

.recording-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    animation: pulse-dot 1s ease infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

/* =========================================
   RESULT SECTION
   ========================================= */
.stt-result,
.ocr-result {
    min-height: 120px;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.placeholder-icon-large {
    font-size: 36px;
    opacity: 0.4;
}

.result-content {
    display: none;
}

.result-content.visible {
    display: block;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.result-text-container {
    margin-bottom: 16px;
}

.extracted-text {
    width: 100%;
    min-height: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    resize: vertical;
    line-height: 1.7;
}

.extracted-text:focus {
    outline: none;
    border-color: var(--accent);
}

.result-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* Audio result */
.audio-result {
    min-height: 100px;
}

.audio-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.audio-controls {
    display: none;
}

.audio-controls.visible {
    display: block;
}

.control-buttons {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.audio-info {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* =========================================
   LOADING
   ========================================= */
.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-indicator.visible {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* =========================================
   ERROR / SUCCESS
   ========================================= */
.error-box,
.error-message {
    display: none;
    padding: 12px 16px;
    background: var(--danger-dim);
    border: 1px solid rgba(255, 77, 77, 0.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--danger);
    margin-top: 14px;
}

.error-box.visible,
.error-message.visible {
    display: block;
}

/* =========================================
   LOGIN PAGE
   ========================================= */
.login-page {
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

/* Subtle grid background */
.login-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 229, 200, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 229, 200, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-elevated);
}

.logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-image {
    height: 48px;
    margin-bottom: 16px;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    margin-bottom: 6px;
}

.logo p {
    font-size: 13px;
    color: var(--text-secondary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.login-form input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-primary);
    transition: border-color var(--transition);
    width: 100%;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 229, 200, 0.08);
}

.login-form input::placeholder {
    color: var(--text-muted);
}

.login-form .btn-primary {
    margin-top: 8px;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.login-info {
    margin-top: 24px;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.8;
}

.login-info strong {
    color: var(--text-secondary);
}

.login-info code {
    background: rgba(0, 229, 200, 0.1);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

/* =========================================
   SCROLLBAR
   ========================================= */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =========================================
   ACCENT HIGHLIGHT on nav active indicator
   ========================================= */
.nav-menu>li>a.active::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

.nav-menu>li {
    position: relative;
}