/* ============================================
   Sirob Portal — Shared Styles
   ============================================ */

/* --- CSS Variables (matching index.html) --- */
:root {
    --accent: #e17f38;
    --accent-hover: #c96c2b;
    --heading: #22374a;
    --text: #3f485a;
    --muted: #6b7280;
    --bg: #ffffff;
    --card: #ffffff;
    --border: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --sidebar-bg: #f8fafc;
    --sidebar-width: 260px;
    --input-bg: var(--bg);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

[data-theme="dark"] {
    --accent: #e17f38;
    --accent-hover: #f19555;
    --heading: #f8fafc;
    --text: #cbd5e1;
    --muted: #94a3b8;
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --sidebar-bg: #1a2332;
    --input-bg: #0f172a;
}

/* --- Base --- */
body {
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    min-height: 100vh;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* --- Sidebar Layout --- */
.portal-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--heading);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: var(--heading);
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background-color: rgba(225, 127, 56, 0.06);
}

.nav-link svg,
.nav-link i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    padding: 0.375rem;
    margin-left: -0.375rem;
    transition: background-color 0.15s;
}

a.sidebar-user:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] a.sidebar-user:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg);
    position: sticky;
    top: 0;
    z-index: 30;
}

.portal-topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--heading);
    margin: 0;
}

.portal-main {
    padding: 2rem;
    flex: 1;
}

/* Mobile hamburger */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--heading);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 35;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    gap: 0.5rem;
    border: none;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.5;
}

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

.btn-primary {
    background-color: var(--accent);
    color: white;
    border: 1px solid transparent;
}
.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: transparent;
    color: var(--heading);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    background-color: transparent;
    color: var(--muted);
    padding: 0.375rem;
    border-radius: 6px;
}
.btn-ghost:hover {
    color: var(--heading);
    background-color: rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .btn-ghost:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* --- Form Inputs --- */
.input-field {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--heading);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(225, 127, 56, 0.1);
}

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

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

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.input-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--heading);
    margin-bottom: 0.375rem;
}

.input-group {
    margin-bottom: 1rem;
}

.input-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.5em;
    font-size: 1.5rem;
    text-align: center;
}

/* --- Cards --- */
.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(225, 127, 56, 0.1);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-blue {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}
[data-theme="dark"] .badge-blue {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-yellow {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
}
[data-theme="dark"] .badge-yellow {
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.badge-green {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
}
[data-theme="dark"] .badge-green {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge-gray {
    background-color: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}
[data-theme="dark"] .badge-gray {
    background-color: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.badge-accent {
    background-color: rgba(225, 127, 56, 0.1);
    color: var(--accent);
}

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tbody tr {
    transition: background-color 0.1s ease;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}
[data-theme="dark"] .data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Tabs --- */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--heading);
}

.tab-btn.active {
    border-bottom-color: var(--accent);
    color: var(--heading);
    font-weight: 600;
}

.tab-panel {
    display: none;
}

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

/* --- Message Thread --- */
.message-thread {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-bubble {
    padding: 1rem;
    border-radius: 10px;
    background-color: var(--card);
    border: 1px solid var(--border);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.message-author {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--heading);
}

.message-time {
    font-size: 0.75rem;
    color: var(--muted);
}

.message-body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}

.badge-support {
    display: inline-flex;
    align-items: center;
    padding: 0.0625rem 0.375rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: rgba(225, 127, 56, 0.15);
    color: var(--accent);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

/* --- Alert / Banner --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #d97706;
}
[data-theme="dark"] .alert-warning {
    color: #fbbf24;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #059669;
}
[data-theme="dark"] .alert-success {
    color: #34d399;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
}
[data-theme="dark"] .alert-error {
    color: #f87171;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #2563eb;
}
[data-theme="dark"] .alert-info {
    color: #60a5fa;
}

/* --- Toggle Switch --- */
.toggle-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.toggle-option {
    flex: 1;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    transition: all 0.15s ease;
}

.toggle-option.active {
    background-color: var(--accent);
    color: white;
}

/* --- Avatar Upload --- */
.avatar-upload {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.avatar-upload:hover {
    opacity: 0.85;
}

.avatar-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload .avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.avatar-upload:hover .avatar-overlay {
    opacity: 1;
}

/* --- Loading Spinner --- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* --- Download Cards --- */
.download-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
}

.download-card:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(225, 127, 56, 0.1);
}

.download-card.recommended {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(225, 127, 56, 0.15);
    position: relative;
}

.download-card .os-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--heading);
}

.download-card .os-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 0.25rem;
}

.download-card .os-info {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    color: var(--heading);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideInRight 0.3s ease;
    max-width: 360px;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-toggle {
        display: flex;
    }

    .mobile-overlay.active {
        display: block;
    }

    .portal-content {
        margin-left: 0;
    }

    .portal-main {
        padding: 1rem;
    }

    .portal-topbar {
        padding: 1rem;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
    }

    .tab-btn {
        padding: 0.625rem 0.75rem;
        font-size: 0.8125rem;
    }

    .download-card {
        padding: 1.25rem;
    }
}
