/* ============================================================
   EsteiraDev Dashboard — CSS
   Inspired by Mercury Bank's clean, modern dashboard design
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Mercury-inspired palette */
    --bg-primary: #f7f8fa;
    --bg-white: #ffffff;
    --bg-sidebar: #1a1d23;
    --bg-sidebar-hover: #272a31;
    --bg-sidebar-active: #2d3039;

    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-sidebar: #9ca3af;
    --text-sidebar-active: #ffffff;

    --accent-primary: #5046e5;
    --accent-primary-light: #eef2ff;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;

    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --sidebar-width: 260px;
    --header-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.logo-text {
    color: white;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--bg-sidebar-hover);
    color: white;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #d1d5db;
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    color: var(--text-sidebar);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.nav-badge.accent {
    background: rgba(80, 70, 229, 0.3);
    color: #a5b4fc;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 12px 0;
}

.nav-label {
    color: rgba(255,255,255,0.3);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 4px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 500;
}

.user-role {
    color: var(--text-sidebar);
    font-size: 11px;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === HEADER === */
.header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left { flex: 1; max-width: 480px; }

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    transition: all 0.2s;
}

.search-bar:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.1);
}

.search-bar svg { color: var(--text-tertiary); flex-shrink: 0; }

.search-bar input {
    border: none;
    background: none;
    outline: none;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}

.search-bar input::placeholder { color: var(--text-tertiary); }

.search-bar kbd {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.header-btn:hover {
    background: var(--bg-primary);
    border-color: #d1d5db;
}

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

.primary-btn:hover {
    background: #4338ca !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(80, 70, 229, 0.3);
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-white);
}

/* === CONTENT AREA === */
.content-area {
    padding: 28px;
    flex: 1;
}

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

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.period-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* === METRICS GRID === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s;
}

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

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

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

.metric-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon.blue { background: #eff6ff; color: var(--accent-blue); }
.metric-icon.green { background: #ecfdf5; color: var(--accent-green); }
.metric-icon.purple { background: #f5f3ff; color: var(--accent-purple); }
.metric-icon.orange { background: #fffbeb; color: var(--accent-orange); }

.metric-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 8px;
}

.metric-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
}

.metric-change.positive { color: var(--accent-green); }
.metric-change.neutral { color: var(--text-tertiary); }

/* === DASHBOARD GRID === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* === CARD BASE === */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.card-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.card-badge.live {
    background: #ecfdf5;
    color: var(--accent-green);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.card-link {
    font-size: 12px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.card-link:hover { text-decoration: underline; }

/* === PIPELINE FLOW === */
.pipeline-card { grid-column: 1 / -1; }

.pipeline-flow {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 0;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    flex: 1;
    min-width: 0;
}

.pipeline-step.completed { background: #ecfdf5; }
.pipeline-step.active { background: var(--accent-primary-light); }
.pipeline-step.pending { background: var(--bg-primary); }

.step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pipeline-step.completed .step-icon { background: var(--accent-green); color: white; }
.pipeline-step.active .step-icon { background: var(--accent-primary); color: white; }
.pipeline-step.pending .step-icon { background: #e5e7eb; color: var(--text-tertiary); }

.step-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.step-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.step-detail {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pipeline-connector {
    width: 32px;
    height: 2px;
    background: #e5e7eb;
    flex-shrink: 0;
}

.pipeline-connector.completed { background: var(--accent-green); }
.pipeline-connector.active {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-primary));
}

.spinning {
    animation: spin 1.5s linear infinite;
}

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

/* === ACTIVITY LIST === */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.activity-dot.green { background: var(--accent-green); }
.activity-dot.blue { background: var(--accent-blue); }
.activity-dot.orange { background: var(--accent-orange); }
.activity-dot.purple { background: var(--accent-purple); }

.activity-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.activity-text {
    font-size: 13px;
    color: var(--text-primary);
}

.activity-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* === MODULES TABLE === */
.modules-card { grid-column: 1 / -1; }

.filter-input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    background: var(--bg-primary);
    outline: none;
    width: 160px;
}

.filter-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(80, 70, 229, 0.1);
}

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

.modules-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.modules-table td {
    padding: 14px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.modules-table tr:hover td { background: var(--bg-primary); }
.modules-table tr:last-child td { border-bottom: none; }

.tag {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.count {
    background: var(--bg-primary);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.green { background: var(--accent-green); }
.status-dot.orange { background: var(--accent-orange); }
.status-dot.yellow { background: #eab308; }
.status-dot.gray { background: #d1d5db; }

.status-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.complete { background: #ecfdf5; color: var(--accent-green); }
.status-badge.running { background: var(--accent-primary-light); color: var(--accent-primary); }
.status-badge.review { background: #fffbeb; color: #d97706; }
.status-badge.pending { background: var(--bg-primary); color: var(--text-tertiary); }

/* === COST CARD === */
.cost-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cost-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.cost-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1.5px;
}

.cost-period {
    font-size: 13px;
    color: var(--text-tertiary);
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.cost-row span:last-child { font-weight: 600; color: var(--text-primary); }

.cost-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.cost-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: 3px;
    transition: width 1s ease;
}

.cost-limit {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* === DEMO TOOLTIP (Supademo-style) === */
.demo-tooltip {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-sidebar);
    color: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    width: 320px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    animation: tooltipIn 0.5s 1s forwards;
}

@keyframes tooltipIn {
    to { opacity: 1; transform: translateY(0); }
}

.demo-tooltip-header {
    margin-bottom: 8px;
}

.demo-step-indicator {
    font-size: 11px;
    color: var(--text-sidebar);
    font-weight: 600;
}

.demo-tooltip-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    color: #e5e7eb;
}

.demo-tooltip-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.demo-btn-secondary, .demo-btn-primary {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.demo-btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #d1d5db;
}

.demo-btn-secondary:hover { background: rgba(255,255,255,0.15); }

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

.demo-btn-primary:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

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