/* CSS Variables for theming */
:root {
    /* Light theme (default) */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a2e;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --accent-color: #0d6efd;
    --accent-hover: #0b5ed7;
    --accent-light: #e7f1ff;
    --success-color: #198754;
    --success-light: #d1e7dd;
    --warning-color: #ffc107;
    --warning-light: #fff3cd;
    --danger-color: #dc3545;
    --danger-light: #f8d7da;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --accent-color: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-light: #1f3a5f;
    --success-color: #3fb950;
    --success-light: #1a4028;
    --warning-color: #d29922;
    --warning-light: #3d2e00;
    --danger-color: #f85149;
    --danger-light: #4a1c1c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-user {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 52px;
    z-index: 99;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
}

.nav-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--accent-color);
    border-radius: 3px 3px 0 0;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.nav-tab.active {
    color: var(--accent-color);
}

.nav-tab.active::after {
    width: 40px;
}

.nav-icon {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Section Headers */
.section-header {
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Cards */
.card-list {
    margin-bottom: 24px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
}

.badge-requested {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-assigned {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-closed {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.card-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-row {
    display: flex;
    margin-bottom: 4px;
}

.card-label {
    color: var(--text-muted);
    min-width: 80px;
}

.card-value {
    color: var(--text-primary);
    word-break: break-word;
}

.card-id {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 8px;
}

/* Username links */
.username-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.username-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.username-link:active {
    opacity: 0.8;
}

/* Loading and Empty States */
.loading, .empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.action-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.action-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-md);
}

.action-card:active {
    transform: scale(0.98);
}

.action-icon {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.action-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.action-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Forms */
.action-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
    animation: slideUp 0.3s ease;
}

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

.action-form.hidden {
    display: none;
}

.action-form h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-field {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn:active {
    transform: scale(0.97);
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.settings-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.theme-switch {
    display: flex;
    gap: 8px;
}

.theme-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.theme-btn:hover {
    border-color: var(--accent-color);
}

.theme-btn.active {
    background: var(--accent-light);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.user-info-card {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.user-info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.user-info-row:last-child {
    border-bottom: none;
}

.user-info-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.user-info-value {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Help List */
.help-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-item {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.help-item summary {
    padding: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-item summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--text-muted);
}

.help-item[open] summary::after {
    content: '-';
}

.help-item ul {
    padding: 0 12px 12px;
    list-style: none;
}

.help-item li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.help-item li:last-child {
    border-bottom: none;
}

.help-item code {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
}

.toast.success {
    background: var(--success-light);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.toast.error {
    background: var(--danger-light);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.toast.info {
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

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

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

/* Responsive adjustments */
@media (max-width: 400px) {
    .action-grid {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .main-content {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
