/* SocialUpload - Mobile-First Styles */

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-heading: #f1f5f9;
    --border: #2d2d44;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --recording: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Header */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-heading);
}

.app-header .user-info {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Main Content */
.app-content {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 24px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-heading);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px; /* Prevents iOS zoom */
    font-family: var(--font);
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
}

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

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    min-height: 48px; /* Touch target */
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

/* Topic Cards */
.topic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.topic-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.topic-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.topic-card h3 {
    font-size: 16px;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.topic-card .meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-draft { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-submitted { background: rgba(79,70,229,0.15); color: var(--primary-light); }
.badge-reviewed { background: rgba(16,185,129,0.15); color: var(--success); }

/* Upload Grid */
.upload-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.upload-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    transition: opacity 0.2s, transform 0.2s;
}

.upload-card.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,0.3);
}

.drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    border-radius: 6px;
    color: #fff;
    cursor: grab;
    z-index: 5;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.upload-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.upload-card .card-body {
    padding: 12px;
}

.upload-card .card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

/* Voice Recording */
.voice-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-btn:hover {
    border-color: var(--primary);
}

.voice-btn.recording {
    border-color: var(--recording);
    background: rgba(239,68,68,0.1);
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

.voice-btn.transcribing {
    border-color: var(--primary);
    opacity: 0.7;
    animation: spin 1s linear infinite;
}

.recording-timer {
    font-size: 13px;
    color: var(--recording);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Caption Area */
.caption-area {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.caption-area textarea {
    flex: 1;
}

/* Upload Area */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(79,70,229,0.05);
}

.upload-zone .icon {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.upload-zone .icon svg {
    width: 40px;
    height: 40px;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 14px;
}

.upload-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.upload-actions .btn {
    flex: 1;
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 20px;
    color: var(--text-heading);
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-family: var(--font);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.back-btn:hover,
.back-btn:active {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.back-btn svg,
.back-btn span {
    pointer-events: none;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: calc(100% - 32px);
    max-width: 400px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    box-shadow: var(--shadow);
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    margin-bottom: 16px;
    opacity: 0.5;
    color: var(--text-muted);
}

.empty-state .icon svg {
    width: 40px;
    height: 40px;
}

.empty-state p {
    margin-bottom: 16px;
}

/* Error Message */
.error-msg {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.error-msg.visible {
    display: block;
}

/* Tab Bar (Footer Navigation) */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    padding: 8px 16px;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab-item:hover,
.tab-item.active {
    color: var(--primary-light);
}

.tab-item.active svg {
    stroke: var(--primary-light);
}

.tab-item.tab-add {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -16px;
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}

.tab-item.tab-add svg {
    stroke: #fff;
}

/* Content padding for tab bar */
.app-content {
    padding-bottom: 80px;
}

/* Submit Bar */
.submit-bar {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    margin-bottom: 16px;
}

/* Upload Progress Item */
.upload-progress-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning);
    color: #000;
    text-align: center;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    z-index: 500;
    animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modal-up 0.3s ease-out;
}

@keyframes modal-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-heading);
}

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

.modal-header h3 {
    margin-bottom: 0;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.btn-close:hover {
    color: var(--text);
}

/* Account Menu */
.account-info {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.account-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
}

.account-user {
    font-size: 14px;
    color: var(--text-muted);
}

/* Delete confirm */
.confirm-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.confirm-actions .btn {
    flex: 1;
}

/* PWA Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 300;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    display: none;
}

.install-banner.visible { display: flex; }

.install-banner p {
    font-size: 14px;
    flex: 1;
}

/* Tablet+ */
@media (min-width: 768px) {
    .app-content {
        padding: 24px;
    }

    .upload-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-overlay {
        align-items: center;
    }

    .modal {
        border-radius: var(--radius);
        max-height: 90vh;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .upload-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
