/* static/css/main.css */
/* Основные стили платформы репетиторов */
/* Mobile-First Responsive Design (320px - 1440px+) */

/* === CSS Custom Properties === */
:root {
    /* Colors */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    --shadow-color: rgba(0,0,0,0.05);
    --shadow-hover: rgba(0,0,0,0.1);
    --accent-primary: #007bff;
    --accent-secondary: #0056b3;
    --header-gradient-start: #007bff;
    --header-gradient-end: #0056b3;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Touch target minimum size (44px recommended by Apple, 48px by Google) */
    --touch-target-min: 44px;

    /* Container max widths */
    --container-sm: 540px;
    --container-md: 720px;
    --container-lg: 960px;
    --container-xl: 1200px;

    /* Breakpoints reference (for documentation):
       - xs: 0 - 479px (small phones)
       - sm: 480px - 767px (large phones)
       - md: 768px - 1023px (tablets)
       - lg: 1024px - 1439px (small desktop)
       - xl: 1440px+ (large desktop)
    */
}

/* === Reset & Base (Mobile-First) === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

main {
    flex: 1;
}

/* Prevent overflow from any element */
img,
video,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

/* === Container (Mobile-First) === */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: var(--spacing-md);
    /* Prevent horizontal overflow */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Container breakpoints */
@media (min-width: 480px) {
    .container {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
        padding: var(--spacing-lg);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: var(--container-lg);
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

@media (min-width: 1440px) {
    .container {
        max-width: var(--container-xl);
    }
}

/* === Header (Mobile-First) === */
header {
    background: linear-gradient(135deg, var(--header-gradient-start) 0%, var(--header-gradient-end) 100%);
    color: white;
    padding: var(--spacing-sm) 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: center;
    text-align: center;
}

header h1 {
    font-size: 1.25rem;
    margin: 0;
}

.logo-link {
    color: white;
    text-decoration: none;
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
}

.logo-link:hover {
    opacity: 0.9;
}

@media (min-width: 480px) {
    header .container {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

/* === Language Switcher (Mobile-First) === */
.language-switcher {
    display: flex;
    gap: var(--spacing-xs);
}

.lang-btn {
    /* Touch-friendly size */
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover,
.lang-btn:focus {
    background: rgba(255, 255, 255, 0.25);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.lang-btn.active {
    background: white;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Dark theme support for language switcher */
[data-theme="dark"] .lang-btn {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .lang-btn.active {
    background: rgba(255, 255, 255, 0.95);
    color: #1e1e1e;
}

/* === Navigation (Mobile-First) === */
nav {
    background: var(--accent-secondary);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    gap: 0;
    padding: 0 var(--spacing-sm);
}

.nav-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

nav li {
    margin: 0;
    flex-shrink: 0;
}

nav a {
    color: white;
    text-decoration: none;
    /* Touch-friendly: minimum 44px height */
    padding: var(--spacing-md) var(--spacing-md);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    transition: background 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}

nav a:hover,
nav a:focus {
    background: rgba(255,255,255,0.1);
    outline: none;
}

@media (min-width: 768px) {
    .nav-list {
        justify-content: center;
        overflow-x: visible;
        padding: 0;
    }

    nav a {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 1rem;
    }
}

/* === Buttons (Mobile-First with touch-friendly sizes) === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Touch-friendly minimum size */
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Prevent text from causing overflow */
    word-break: break-word;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-secondary);
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover,
.btn-success:focus {
    background: #1e7e34;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover,
.btn-danger:focus {
    background: #bd2130;
}

.btn-block {
    display: flex;
    width: 100%;
}

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

/* Larger buttons on desktop */
@media (min-width: 768px) {
    .btn {
        min-height: 40px;
        padding: 0.625rem 1.25rem;
    }
}

/* === Forms (Mobile-First) === */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: #444;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    /* Touch-friendly input height */
    min-height: var(--touch-target-min);
    padding: var(--spacing-md);
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem; /* 16px prevents iOS zoom on focus */
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #999;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

@media (min-width: 480px) {
    .form-actions {
        flex-direction: row;
    }
}

.char-count {
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: #999;
    margin-top: var(--spacing-xs);
}

/* === Alerts === */
.alert {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-radius: 8px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* === Cards (Mobile-First) === */
.card {
    background: white;
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-radius: 12px;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

.card h3, .card h4 {
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

@media (min-width: 768px) {
    .card {
        padding: var(--spacing-lg);
    }

    .card:hover {
        transform: translateY(-5px);
        box-shadow: 0 12px 24px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    }
}

/* === Page Headers (Mobile-First) === */
.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.page-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

@media (min-width: 480px) {
    .page-header h2 {
        font-size: 1.75rem;
    }
}

@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.page-description {
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

.back-link {
    margin-bottom: var(--spacing-md);
}

.back-link a {
    color: var(--accent-primary);
    text-decoration: none;
    /* Touch-friendly */
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) 0;
}

.back-link a:hover {
    text-decoration: underline;
}

/* === Loading Spinner === */
.loading-spinner {
    text-align: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

@media (min-width: 768px) {
    .empty-icon {
        font-size: 4rem;
    }
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

/* === Auth Pages (Mobile-First) === */
.auth-container {
    max-width: 100%;
    margin: var(--spacing-md) auto;
    padding: 0;
}

@media (min-width: 480px) {
    .auth-container {
        max-width: 400px;
        margin: var(--spacing-xl) auto;
    }
}

@media (min-width: 768px) {
    .auth-container {
        max-width: 450px;
    }
}

.auth-card {
    padding: var(--spacing-lg);
}

@media (min-width: 480px) {
    .auth-card {
        padding: var(--spacing-xl);
    }
}

.auth-title {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    font-size: 1.25rem;
}

@media (min-width: 480px) {
    .auth-title {
        font-size: 1.5rem;
    }
}

.auth-footer {
    text-align: center;
    margin-top: var(--spacing-lg);
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    /* Touch-friendly inline link */
    padding: var(--spacing-xs) 0;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Role Selector (Mobile-First) */
.role-selector {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

@media (min-width: 480px) {
    .role-selector {
        grid-template-columns: 1fr 1fr;
    }
}

.role-option {
    cursor: pointer;
}

.role-option input {
    display: none;
}

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Touch-friendly */
    padding: var(--spacing-lg);
    min-height: 120px;
    border: 2px solid #ddd;
    border-radius: 12px;
    transition: all 0.2s;
    text-align: center;
}

.role-option input:checked + .role-card {
    border-color: var(--accent-primary);
    background: #f0f7ff;
}

.role-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
}

.role-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

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

/* === Specialists Page (Mobile-First) === */
.search-filters {
    margin-bottom: var(--spacing-lg);
}

.filters-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    align-items: end;
}

@media (min-width: 480px) {
    .filters-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) {
    .filters-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .filters-row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

.filter-group {
    margin-bottom: 0;
}

.specialists-stats {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.specialists-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

@media (min-width: 480px) {
    .specialists-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (min-width: 768px) {
    .specialists-grid {
        gap: var(--spacing-lg);
    }
}

.specialist-card {
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                border-color 0.3s ease;
}

@media (min-width: 768px) {
    .specialist-card:hover {
        transform: translateY(-8px) scale(1.02);
        box-shadow: 0 20px 40px rgba(0,123,255,0.15), 0 8px 16px rgba(0,0,0,0.1);
        border-color: var(--accent-primary);
    }
}

.specialist-card h3 {
    margin-bottom: var(--spacing-sm);
}

.specialist-card .price {
    color: #28a745;
    font-weight: 600;
    font-size: 1.1rem;
}

.specialist-card .bio {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: var(--spacing-sm) 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.specialist-card .card-footer {
    margin-top: auto;
    padding-top: var(--spacing-md);
}

/* === Orders Page (Mobile-First) === */
.orders-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.tab-btn {
    /* Touch-friendly */
    min-height: var(--touch-target-min);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid #ddd;
    background: white;
    border-radius: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab-btn:hover,
.tab-btn:focus {
    background: #f5f5f5;
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.order-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

@media (min-width: 768px) {
    .order-card {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    .order-card:hover {
        transform: translateX(5px);
        box-shadow: -4px 0 0 var(--accent-primary), 0 4px 12px rgba(0,0,0,0.08);
        background: #fafbfc;
    }
}

.order-card .order-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.order-card h4 {
    margin-bottom: var(--spacing-sm);
    word-break: break-word;
}

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

.order-status {
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-pending { background: #fff3cd; color: #856404; }
.status-in_progress { background: #d1ecf1; color: #0c5460; }
.status-completed { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* === Chat/Messages Page (Mobile-First) === */
.messages-page {
    height: calc(100vh - 200px);
    min-height: 400px;
}

@media (min-width: 768px) {
    .messages-page {
        height: calc(100vh - 250px);
        min-height: 500px;
    }
}

.messages-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .messages-container {
        display: grid;
        grid-template-columns: 280px 1fr;
    }
}

@media (min-width: 1024px) {
    .messages-container {
        grid-template-columns: 320px 1fr;
    }
}

.conversations-sidebar {
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 180px;
    overflow: hidden;
}

@media (min-width: 768px) {
    .conversations-sidebar {
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        max-height: none;
    }
}

.conversations-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.conversations-header h3 {
    margin: 0;
    font-size: 1rem;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.conversation-item {
    /* Touch-friendly */
    padding: var(--spacing-md);
    min-height: var(--touch-target-min);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-item:hover {
    background: #f5f7fa;
}

@media (min-width: 768px) {
    .conversation-item:hover {
        transform: translateX(5px);
        background: linear-gradient(90deg, #e8f4ff 0%, #f5f7fa 100%);
    }
}

.conversation-item.active {
    background: #e8f4ff;
    border-left: 3px solid var(--accent-primary);
}

.conversation-name {
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.conversation-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Important for flex children with overflow */
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: var(--spacing-lg);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

@media (min-width: 768px) {
    .placeholder-icon {
        font-size: 4rem;
    }
}

.active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.message {
    max-width: 85%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 16px;
    position: relative;
    word-break: break-word;
}

@media (min-width: 768px) {
    .message {
        max-width: 70%;
    }
}

.message.sent {
    background: var(--accent-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.received {
    background: var(--bg-tertiary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: var(--spacing-xs);
}

.chat-form {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input-row,
.chat-input-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-end;
}

.chat-form textarea {
    flex: 1;
    resize: none;
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: var(--touch-target-min);
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 1rem; /* 16px prevents iOS zoom */
}

.chat-form .send-btn {
    border-radius: 50%;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    padding: 0;
    flex-shrink: 0;
}

/* === Profile Page (Mobile-First) === */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
}

@media (min-width: 768px) {
    .profile-grid {
        grid-template-columns: 2fr 1fr;
    }
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

@media (min-width: 480px) {
    .profile-header {
        flex-direction: row;
        align-items: center;
        text-align: left;
    }
}

.profile-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    flex-shrink: 0;
}

@media (min-width: 480px) {
    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 1.75rem;
    }
}

.profile-avatar.large {
    width: 90px;
    height: 90px;
    font-size: 1.75rem;
}

@media (min-width: 480px) {
    .profile-avatar.large {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }
}

.profile-title h3 {
    margin: 0 0 var(--spacing-xs);
}

.role-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.role-badge.client {
    background: #e8f4ff;
    color: var(--accent-primary);
}

.role-badge.specialist {
    background: #e8fff0;
    color: #28a745;
}

.profile-info,
.profile-details {
    margin-bottom: var(--spacing-md);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
}

@media (min-width: 480px) {
    .detail-item {
        flex-direction: row;
        gap: var(--spacing-sm);
    }
}

.detail-label {
    color: var(--text-secondary);
    min-width: 100px;
    flex-shrink: 0;
}

.detail-value {
    font-weight: 500;
    word-break: break-word;
}

.detail-value.price {
    color: #28a745;
}

.profile-bio {
    color: var(--text-secondary);
    margin: var(--spacing-md) 0;
    line-height: 1.7;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

@media (min-width: 480px) {
    .profile-actions {
        flex-direction: row;
    }
}

/* Stats Card */
.stats-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    text-align: center;
}

@media (min-width: 768px) {
    .stats-list {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
}

.stat-item {
    padding: var(--spacing-sm);
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
}

@media (min-width: 768px) {
    .stat-value {
        font-size: 1.5rem;
    }
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@media (min-width: 768px) {
    .stat-label {
        font-size: 0.8rem;
    }
}

/* Quick Links */
.quick-links ul {
    list-style: none;
}

.quick-links li {
    margin-bottom: var(--spacing-sm);
}

.quick-links a {
    color: var(--accent-primary);
    text-decoration: none;
    /* Touch-friendly */
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target-min);
    padding: var(--spacing-xs) 0;
}

.quick-links a:hover {
    text-decoration: underline;
}

/* === Rating Input === */
.rating-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.rating-input input {
    display: none;
}

.rating-input label {
    font-size: 2rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
    /* Touch-friendly tap area */
    padding: var(--spacing-xs);
}

.rating-input label:hover,
.rating-input label:hover ~ label,
.rating-input input:checked ~ label {
    color: #ffc107;
}

/* Rating Display */
.rating {
    color: #ffc107;
    font-size: 1rem;
}

/* === Reviews === */
.reviews-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.review-item {
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.review-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
}

@media (min-width: 480px) {
    .review-header {
        flex-direction: row;
        justify-content: space-between;
    }
}

.review-author {
    font-weight: 500;
}

.review-rating {
    color: #ffc107;
}

.review-comment {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.review-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--spacing-sm);
}

/* === Subjects/Tags === */
.subjects-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.subject-tag {
    display: inline-block;
    /* Touch-friendly */
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: 32px;
    background: #e8f4ff;
    color: var(--accent-primary);
    border-radius: 20px;
    font-size: 0.85rem;
}

/* === Footer === */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: var(--spacing-md) 0;
    margin-top: auto;
}

/* === Toast Notifications (Mobile-First) === */
.toast-container {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    /* Mobile: bottom positioning */
    left: var(--spacing-md);
    right: var(--spacing-md);
    bottom: calc(var(--spacing-xl) + 60px); /* Above theme toggle */
}

@media (min-width: 768px) {
    .toast-container {
        /* Desktop: top-right positioning */
        top: 20px;
        right: 20px;
        left: auto;
        bottom: auto;
        width: auto;
    }
}

.toast {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: var(--spacing-md);
    border-radius: 12px;
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15), 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    pointer-events: auto;
    transform: translateY(120%);
    opacity: 0;
    animation: toastSlideUp 0.4s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

@media (min-width: 768px) {
    .toast {
        min-width: 300px;
        max-width: 450px;
        transform: translateX(120%);
        animation: toastSlideIn 0.4s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    }
}

.toast.hiding {
    animation: toastSlideDown 0.3s cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
}

@media (min-width: 768px) {
    .toast.hiding {
        animation: toastSlideOut 0.3s cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
    }
}

@keyframes toastSlideUp {
    from {
        transform: translateY(120%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastSlideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(120%);
        opacity: 0;
    }
}

@keyframes toastSlideIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.toast-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    color: #1a1a1a;
}

.toast-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    /* Touch-friendly */
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: var(--spacing-sm);
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: calc(-1 * var(--spacing-sm));
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 12px 12px;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast.success .toast-icon { background: #d4edda; color: #28a745; }
.toast.success .toast-progress { background: #28a745; }

.toast.error .toast-icon { background: #f8d7da; color: #dc3545; }
.toast.error .toast-progress { background: #dc3545; }

.toast.warning .toast-icon { background: #fff3cd; color: #856404; }
.toast.warning .toast-progress { background: #ffc107; }

.toast.info .toast-icon { background: #d1ecf1; color: #0c5460; }
.toast.info .toast-progress { background: #17a2b8; }

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.skeleton-card {
    padding: var(--spacing-lg);
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 6px;
}

.skeleton-image {
    width: 100%;
    height: 150px;
    border-radius: 8px;
}

@media (min-width: 768px) {
    .skeleton-image {
        height: 200px;
    }
}

/* === Ripple Effect === */
.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

.btn-secondary .ripple,
.btn[style*="background: white"] .ripple {
    background: rgba(0,0,0,0.1);
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* === Pulse Badge for Notifications === */
.nav-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -12px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
    }
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
}

/* === Dark Theme === */
[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e4e4e4;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;
    --border-color: #333333;
    --border-light: #2a2a2a;
    --shadow-color: rgba(0,0,0,0.3);
    --shadow-hover: rgba(0,0,0,0.5);
    --accent-primary: #4da3ff;
    --accent-secondary: #2b7de9;
    --header-gradient-start: #1a1a2e;
    --header-gradient-end: #16213e;
}

[data-theme="dark"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] header {
    background: linear-gradient(135deg, var(--header-gradient-start) 0%, var(--header-gradient-end) 100%);
}

[data-theme="dark"] nav {
    background: var(--header-gradient-end);
}

[data-theme="dark"] .card,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .skeleton-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .form-group textarea::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-group label {
    color: var(--text-secondary);
}

[data-theme="dark"] .page-header h2,
[data-theme="dark"] .card h3,
[data-theme="dark"] .card h4 {
    color: var(--text-primary);
}

[data-theme="dark"] .page-description,
[data-theme="dark"] .specialist-card .bio,
[data-theme="dark"] .review-comment {
    color: var(--text-secondary);
}

[data-theme="dark"] footer {
    background: #0a0a0a;
}

[data-theme="dark"] .empty-state h3,
[data-theme="dark"] .detail-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .empty-state p,
[data-theme="dark"] .char-count {
    color: var(--text-muted);
}

[data-theme="dark"] .messages-container,
[data-theme="dark"] .conversations-sidebar,
[data-theme="dark"] .chat-area {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .conversation-item {
    border-color: var(--border-light);
}

[data-theme="dark"] .conversation-item:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .message.received {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .tab-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .tab-btn:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .review-item {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .subject-tag {
    background: rgba(77, 163, 255, 0.15);
    color: var(--accent-primary);
}

[data-theme="dark"] .role-card {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

[data-theme="dark"] .role-option input:checked + .role-card {
    border-color: var(--accent-primary);
    background: rgba(77, 163, 255, 0.1);
}

[data-theme="dark"] .role-desc {
    color: var(--text-secondary);
}

[data-theme="dark"] .toast {
    background: var(--bg-secondary);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

[data-theme="dark"] .toast-title {
    color: var(--text-primary);
}

[data-theme="dark"] .toast-message {
    color: var(--text-secondary);
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
}

[data-theme="dark"] .specialist-card:hover {
    box-shadow: 0 20px 40px rgba(77,163,255,0.2), 0 8px 16px rgba(0,0,0,0.3);
}

[data-theme="dark"] .order-card:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .back-link a,
[data-theme="dark"] .quick-links a,
[data-theme="dark"] .auth-footer a {
    color: var(--accent-primary);
}

/* Theme Toggle Button (Mobile-First) */
.theme-toggle {
    position: fixed;
    z-index: 1000;
    /* Mobile positioning */
    bottom: var(--spacing-md);
    right: var(--spacing-md);
    /* Touch-friendly size */
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 768px) {
    .theme-toggle {
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

.theme-toggle:hover,
.theme-toggle:focus {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5);
    outline: 2px solid white;
    outline-offset: 2px;
}

.theme-toggle:active {
    transform: scale(0.95);
}

[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 20px rgba(240, 147, 251, 0.4);
}

[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 0 6px 30px rgba(240, 147, 251, 0.5);
}

/* === Page Load Animation === */
.fade-in {
    animation: fadeInUp 0.5s ease-out;
}

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

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }

/* === Utility Classes === */
/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Prevent text overflow */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hide on specific breakpoints */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: initial;
    }

    .hide-desktop {
        display: none;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
