/* ============================================
   Octobus Asset Manager — Design System
   Modern Light theme with Soft UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-glass-hover: rgba(0, 0, 0, 0.04);
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --border-active: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-success: #10b981;
    --accent-success-bg: #ecfdf5;
    --accent-warning: #f59e0b;
    --accent-warning-bg: #fffbeb;
    --accent-danger: #ef4444;
    --accent-danger-bg: #fef2f2;
    --accent-info: #3b82f6;
    --accent-info-bg: #eff6ff;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 28px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-glow: 0 0 15px var(--accent-glow);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ============================================
   AUTH LAYOUT
   ============================================ */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.02) 0%, transparent 50%);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* ============================================
   BRAND SELECTION
   ============================================ */
.brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.brand-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.brand-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--brand-color, var(--accent-primary));
    opacity: 0;
    transition: var(--transition);
}

.brand-card:hover {
    transform: translateY(-4px);
    border-color: var(--brand-color, var(--accent-primary));
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 20px color-mix(in srgb, var(--brand-color, var(--accent-primary)) 20%, transparent);
}

.brand-card:hover::before { opacity: 1; }

.brand-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    overflow: hidden;
    background: #fff;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-brand-info h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-brand-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.nav-link svg, .nav-link .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 1rem;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-info .email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.content-body {
    padding: 2rem;
}

/* ============================================
   COMPONENTS
   ============================================ */

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-active);
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.06;
    transform: translate(20px, -20px);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}
.btn-primary:hover {
    background: var(--accent-primary-hover);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-active);
}

.btn-danger {
    background: var(--accent-danger-bg);
    color: var(--accent-danger);
    border-color: rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: var(--accent-danger);
    color: #fff;
}

.btn-success {
    background: var(--accent-success-bg);
    color: var(--accent-success);
    border-color: rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    background: var(--accent-success);
    color: #fff;
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.75rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; min-width: 36px; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-secondary); }

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ---- File Upload ---- */
.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.04);
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.file-upload-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-upload-text strong {
    color: var(--accent-primary);
}

.file-upload-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.file-preview {
    margin-top: 1rem;
    display: none;
}

.file-preview.active { display: block; }

.file-preview img {
    max-height: 200px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* ---- Tables ---- */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

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

th {
    text-align: left;
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

td {
    padding: 0.85rem 1.5rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover td {
    background: #fcfdfe;
}

tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--accent-success-bg);
    color: var(--accent-success);
}
.badge-warning {
    background: var(--accent-warning-bg);
    color: var(--accent-warning);
}
.badge-danger {
    background: var(--accent-danger-bg);
    color: var(--accent-danger);
}
.badge-info {
    background: var(--accent-info-bg);
    color: var(--accent-info);
}

/* ---- Alerts ---- */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: fadeInDown 0.3s ease;
}

.alert-success {
    background: var(--accent-success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
}

.alert-error {
    background: var(--accent-danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

.alert-info {
    background: var(--accent-info-bg);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--accent-info);
}

/* ---- Asset Preview ---- */
.asset-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.asset-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.asset-meta {
    display: flex;
    flex-direction: column;
}

.asset-meta .title {
    font-weight: 600;
    color: var(--text-primary);
}

.asset-meta .key {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'SFMono-Regular', monospace;
}

/* ---- Token display ---- */
.token-display, code.token-display {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.78rem;
    color: var(--accent-primary);
    word-break: break-all;
    max-width: 100%;
}

.token-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.token-wrapper .token-display {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Quick Actions ---- */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.quick-action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}

.quick-action-card:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.quick-action-icon {
    font-size: 1.5rem;
}

.quick-action-text {
    font-weight: 600;
    font-size: 0.9rem;
}

/* ---- Search ---- */
.search-bar {
    position: relative;
    max-width: 320px;
}

.search-bar input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.search-bar input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

/* ---- Recent Assets ---- */
.recent-list {
    margin-top: 1rem;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

/* ---- Copy button ---- */
.btn-copy {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    transition: var(--transition);
}
.btn-copy:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}
.btn-copy.copied {
    background: var(--accent-success-bg);
    color: var(--accent-success);
    border-color: rgba(16, 185, 129, 0.3);
}

/* ---- Confirm Dialog ---- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.confirm-overlay.active { display: flex; }

.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: fadeInUp 0.2s ease;
}

.confirm-dialog h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.confirm-dialog p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.confirm-dialog .btn-group {
    justify-content: center;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* Staggered animation delays */
.animate-delay-1 { animation-delay: 0.05s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.15s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.2s; opacity: 0; }

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

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

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

    .content-body { padding: 1rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .brand-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }

    .table-wrapper { overflow-x: auto; }

    table { min-width: 600px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .brand-grid { grid-template-columns: 1fr; }
}
