/**
 * FashionTrack Styles
 * Modern, clean design system
 */

:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    color: var(--text);
}

h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 24px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px;
}

/* Sidebar */
.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg);
    color: var(--accent);
}

.sidebar-nav svg {
    width: 20px;
    height: 20px;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.metric-icon.accent { background: #e0e7ff; color: var(--accent); }
.metric-icon.success { background: #d1fae5; color: var(--success); }
.metric-icon.warning { background: #fef3c7; color: var(--warning); }
.metric-icon.danger { background: #fee2e2; color: var(--danger); }

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.metric-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

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

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-full {
    width: 100%;
}

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

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

.time-filter {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
    background: var(--card);
    cursor: pointer;
}

/* Chart containers */
.card canvas {
    max-height: 300px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
}

td {
    font-size: 14px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-danger {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: var(--warning);
    border: 1px solid #fde68a;
}

.alert-success {
    background: #d1fae5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

/* Auth Page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.auth-card {
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h1 {
    color: var(--accent);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--muted);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Chat Widget */
.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 1000;
}

.chat-toggle-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.chat-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 48px);
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 1000;
}

.chat-panel.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.chat-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message .message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user .message-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-content {
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-message.error .message-content {
    background: #fee2e2;
    color: var(--danger);
}

.chat-message.loading .message-content {
    padding: 16px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.chat-input-container textarea {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

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

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

/* Chat responsive */
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 16px;
        height: 60vh;
    }
    
    .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
    }
    
    .modal-content {
        margin: 16px;
        max-width: calc(100vw - 32px);
    }
}

/* Utilities */
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
