/* ============================================
   Bid Agent — Responsive Dark Theme
   Mobile-first, works on phone & desktop
   ============================================ */

:root {
    --bg: #0d1117;
    --bg-elevated: #161b22;
    --bg-input: #0d1117;
    --border: #30363d;
    --border-focus: #58a6ff;
    --text: #e6edf3;
    --text-muted: #7d8590;
    --accent: #1f6feb;
    --accent-hover: #388bfd;
    --green: #238636;
    --green-hover: #2ea043;
    --red: #da3633;
    --orange: #d29922;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Login
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-height: 100dvh;
}

.login-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-box form { display: flex; flex-direction: column; gap: 12px; }

.login-box input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.15s;
}

.login-box input:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}

.login-box button {
    width: 100%;
    padding: 14px;
    background: var(--green);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.login-box button:hover { background: var(--green-hover); }
.login-box button:active { transform: scale(0.98); }

.login-box .error {
    background: rgba(218,54,51,0.1);
    border: 1px solid var(--red);
    color: #f85149;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: left;
}

/* ============================================
   Header
   ============================================ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-right span {
    color: var(--text-muted);
    font-size: 13px;
    display: none;
}

/* ============================================
   Main content
   ============================================ */
main {
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* ============================================
   Client cards
   ============================================ */
.clients-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.client-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.client-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow);
}

.client-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.client-header h3 {
    font-size: 15px;
    font-weight: 600;
    word-break: break-word;
}

.badge {
    background: rgba(31,111,235,0.12);
    color: var(--border-focus);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.client-stats {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.client-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s, transform 0.1s;
    min-height: 40px;
    flex: 1;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #484f58; }
.btn-success { background: var(--accent); color: white; }
.btn-success:hover { background: var(--accent-hover); }
.btn-small {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 32px;
    flex: none;
}

/* ============================================
   Strategy form
   ============================================ */
.strategy-form {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.strategy-form.open { display: grid; }

.strategy-form input {
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    width: 100%;
}

.strategy-form input:focus {
    border-color: var(--border-focus);
    outline: none;
}

.strategy-form .btn-success {
    grid-column: 1 / -1;
}

/* ============================================
   Campaigns
   ============================================ */
.campaigns-section { display: none; }
.campaigns-section.visible { display: block; }
.clients-section.hidden { display: none; }

.back-btn {
    margin-bottom: 16px;
}

.campaign-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.campaign-item h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.campaign-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: var(--text-muted);
    font-size: 12px;
}

.campaign-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.campaign-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.campaign-badges .badge {
    font-size: 11px;
}

/* ============================================
   Toast notifications
   ============================================ */
.toast {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s, transform 0.25s;
    z-index: 1000;
    text-align: center;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ============================================
   Desktop / Tablet (>= 640px)
   ============================================ */
@media (min-width: 640px) {
    header { padding: 14px 24px; }
    header h1 { font-size: 20px; }
    .header-right span { display: inline; }
    main { padding: 24px; }
    .clients-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .strategy-form {
        grid-template-columns: 1fr 1fr 1fr auto;
    }
    .strategy-form .btn-success {
        grid-column: auto;
    }
    .btn { flex: none; }
    .toast {
        left: auto;
        right: 24px;
        bottom: 24px;
        max-width: 360px;
    }
}

/* ============================================
   Large desktop (>= 1024px)
   ============================================ */
@media (min-width: 1024px) {
    .clients-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }
    .client-card { padding: 20px; }
    .client-header h3 { font-size: 16px; }
}

/* ============================================
   Accessibility: respect reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   Strategy form — labeled inputs
   ============================================ */
.strategy-form {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.strategy-form.open { display: flex; }

.strategy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.strategy-row label {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 100px;
}

.strategy-row input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    text-align: right;
}

.strategy-row input:focus {
    border-color: var(--border-focus);
    outline: none;
}

.strategy-form .btn-success {
    margin-top: 4px;
}

/* ============================================
   Campaign item — bid comparison
   ============================================ */
.campaign-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.campaign-header h4 {
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.badge-active { background: rgba(35,134,54,0.15); color: #3fb950; }
.badge-paused { background: rgba(210,153,34,0.15); color: #d29922; }
.badge-archived { background: rgba(125,133,144,0.15); color: #7d8590; }
.badge-blocked { background: rgba(218,54,51,0.15); color: #f85149; }

.bid-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.bid-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bid-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

.bid-value.actual { color: var(--orange); }
.bid-value.strategy { color: var(--border-focus); }

/* Desktop: wider bid boxes */
@media (min-width: 640px) {
    .bid-box { padding: 12px 10px; }
    .bid-label { font-size: 11px; }
    .bid-value { font-size: 18px; }
    .strategy-row label { min-width: 120px; }
}
