/* =========================================
   TrainTeamAI — Main Styles (Premium)
   ========================================= */

:root {
    /* Brand colors from logo */
    --primary: #1a3d5c;
    --primary-dark: #0f2840;
    --primary-light: #e8eef4;
    --primary-50: #f0f4f8;

    --accent: #3d9b4f;
    --accent-dark: #2d7a3c;
    --accent-light: #e6f5e9;
    --accent-50: #f0faf2;

    --teal: #3fa9d5;
    --teal-dark: #2d8bb3;
    --teal-light: #e1f3fa;

    /* Semantic */
    --success: #3d9b4f;
    --success-light: #e6f5e9;
    --warning: #e5a100;
    --warning-light: #fff8e1;
    --danger: #d94444;
    --danger-light: #fde8e8;
    --info: #3fa9d5;
    --info-light: #e1f3fa;

    /* Neutrals */
    --gray-50: #f8f9fb;
    --gray-100: #f1f3f6;
    --gray-200: #e2e6ec;
    --gray-300: #cbd2dc;
    --gray-400: #94a0b4;
    --gray-500: #6b7a90;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --gray-900: #0d1117;
    --white: #ffffff;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Radius */
    --radius: 12px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(26, 61, 92, 0.04);
    --shadow: 0 1px 3px rgba(26, 61, 92, 0.08), 0 1px 2px rgba(26, 61, 92, 0.04);
    --shadow-md: 0 4px 12px rgba(26, 61, 92, 0.08), 0 2px 4px rgba(26, 61, 92, 0.04);
    --shadow-lg: 0 12px 32px rgba(26, 61, 92, 0.10), 0 4px 8px rgba(26, 61, 92, 0.06);
    --shadow-xl: 0 20px 50px rgba(26, 61, 92, 0.12), 0 8px 16px rgba(26, 61, 92, 0.06);
    --shadow-glow: 0 0 20px rgba(61, 155, 79, 0.15);

    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    /* Gradient */
    --gradient-brand: linear-gradient(135deg, #1a3d5c 0%, #2a5a80 50%, #3fa9d5 100%);
    --gradient-accent: linear-gradient(135deg, #3d9b4f 0%, #4db862 100%);
    --gradient-surface: linear-gradient(180deg, #f8f9fb 0%, #f1f3f6 100%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gradient-surface);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent);
}

::selection {
    background: var(--accent-light);
    color: var(--primary-dark);
}

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

/* ---- Top Bar ---- */
.top-bar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(226, 230, 236, 0.6);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(26, 61, 92, 0.04);
}
.top-bar-left {
    flex: 0 0 var(--sidebar-width);
    display: flex;
    align-items: center;
}
.top-bar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}
.top-bar-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    transition: opacity var(--transition);
}
.logo:hover {
    opacity: 0.85;
}
.logo-img {
    height: 36px;
    width: auto;
}

.version-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* ---- Main Wrapper ---- */
.main-wrapper {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--topbar-height));
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    position: sticky;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 1px 0 8px rgba(26, 61, 92, 0.03);
}
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.sidebar-header {
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--gray-100);
}
.sidebar-header h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Step Navigation */
.step-nav {
    padding: 12px;
}
.step-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    position: relative;
}
.step-link:hover {
    background: var(--gray-50);
    color: var(--gray-700);
    transform: translateX(2px);
}
.step-link.step-current {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}
.step-link.step-current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}
.step-link.step-validated {
    color: var(--accent);
}
.step-link.step-validated .step-status-icon {
    color: var(--accent);
}
.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--gray-100);
    color: var(--gray-500);
    flex-shrink: 0;
    transition: all var(--transition);
}
.step-current .step-number {
    background: var(--gradient-brand);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(26, 61, 92, 0.25);
}
.step-validated .step-number {
    background: var(--gradient-accent);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(61, 155, 79, 0.25);
}
.step-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Content ---- */
.content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
}
.content.with-sidebar {
    max-width: calc(1200px + var(--sidebar-width));
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.4;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}
.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-brand);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(26, 61, 92, 0.2);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(26, 61, 92, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-200);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-300);
    box-shadow: var(--shadow);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(217, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) {
    background: #c53a3a;
    box-shadow: 0 4px 16px rgba(217, 68, 68, 0.35);
}

.btn-success {
    background: var(--gradient-accent);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(61, 155, 79, 0.25);
}
.btn-success:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(61, 155, 79, 0.35);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
    border-radius: var(--radius);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font-size: inherit;
    box-shadow: none;
}
.btn-link:hover {
    color: var(--accent);
    text-decoration: none;
}

.btn-generate {
    background: var(--gradient-accent);
    color: var(--white);
    box-shadow: 0 2px 12px rgba(61, 155, 79, 0.25);
}
.btn-generate:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(61, 155, 79, 0.35);
    transform: translateY(-1px);
}
.btn-generate .btn-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    letter-spacing: 0.01em;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition);
    background: var(--white);
    color: var(--gray-800);
}
.form-control:hover {
    border-color: var(--gray-300);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 61, 92, 0.1);
}
.form-control::placeholder {
    color: var(--gray-400);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7a90' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.form-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
    font-weight: 400;
}

/* ---- Cards ---- */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--gray-800);
}
.card-body {
    padding: 20px;
}
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: var(--gray-50);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }

/* ---- Toast Notifications ---- */
#toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 14px 22px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 420px;
    backdrop-filter: blur(10px);
}
.toast-success {
    background: linear-gradient(135deg, #3d9b4f, #4db862);
    color: var(--white);
}
.toast-error {
    background: linear-gradient(135deg, #d94444, #e05757);
    color: var(--white);
}
.toast-warning {
    background: linear-gradient(135deg, #e5a100, #f0b429);
    color: var(--white);
}
.toast-info {
    background: linear-gradient(135deg, #3fa9d5, #5bbde0);
    color: var(--white);
}

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

/* ---- Modal ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(4px);
}
.modal-box {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-dark {
    border-color: rgba(26, 61, 92, 0.1);
    border-top-color: var(--primary);
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Page Title ---- */
.page-header {
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.page-header p {
    color: var(--gray-500);
    font-size: 15px;
    font-weight: 400;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 64px 32px;
    color: var(--gray-500);
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--gray-200);
}
.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
    font-weight: 600;
}
.empty-state p {
    font-size: 14px;
    color: var(--gray-400);
}

/* ---- Drag handle ---- */
.drag-handle {
    cursor: grab;
    color: var(--gray-300);
    font-size: 18px;
    padding: 0 4px;
    user-select: none;
    transition: color var(--transition);
}
.drag-handle:hover {
    color: var(--gray-500);
}
.drag-handle:active {
    cursor: grabbing;
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Scrollbar Global ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}
