/* =============================================================================
   CarveMobile — Main Stylesheet
   Design: Dark monochromatic, system sans-serif. Matches carveoperations.com.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Design Tokens
   --------------------------------------------------------------------------- */
:root {
    /* Surfaces */
    --bg:           #0a0a0a;
    --surface-1:    #111111;
    --surface-2:    #181818;
    --surface-3:    #222222;

    /* Borders */
    --border:       #2a2a2a;
    --border-light: #333333;

    /* Text */
    --text-primary:   #f2f2f2;
    --text-secondary: #8a8a8a;
    --text-muted:     #555555;

    /* Accent — white only, no hue */
    --accent:         #ffffff;
    --accent-dim:     #cccccc;

    /* Status */
    --success:  #4ade80;
    --warning:  #fbbf24;
    --danger:   #f87171;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Font */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    padding-top: 84px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

a {
    color: #60a5fa;
}
a:visited {
    color: #93c5fd;
}
a:hover {
    color: #bfdbfe;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------------------
   Navbar
   --------------------------------------------------------------------------- */
.navbar {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 48px);
    max-width: 1040px;
    z-index: 1000;
    background: rgba(17, 17, 17, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
}

.navbar a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 450;
    letter-spacing: 0.01em;
    transition: color 0.15s;
    white-space: nowrap;
}

.navbar a:hover {
    color: var(--text-primary);
}

.navbar a.active {
    color: var(--text-primary);
    font-weight: 600;
}

.navbar a.navbar-brand {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1em;
    letter-spacing: -0.01em;
    margin-right: 16px;
}

.navbar a.navbar-logo-link {
    display: flex;
    align-items: center;
    padding: 0;
    line-height: 0;
    margin-right: 4px;
}

.navbar-logo {
    height: 28px;
    width: auto;
    display: block;
    flex-shrink: 0;
    opacity: 0.95;
}

/* ---------------------------------------------------------------------------
   Profile / User Dropdown
   --------------------------------------------------------------------------- */
.profile-menu {
    position: relative;
    margin-left: auto;
}

.profile-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--border-light);
}

.profile-initial {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--border-light);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
}

.profile-icon-btn:hover .profile-initial {
    border-color: var(--accent-dim);
}

.profile-initial svg {
    display: block;
}

.profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 260px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
    z-index: 1001;
    overflow: hidden;
}

.profile-dropdown.open {
    display: block;
}

.profile-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.profile-dropdown-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9em;
}

.profile-dropdown-email {
    color: var(--text-secondary);
    font-size: 0.8em;
    margin-top: 2px;
}

.profile-dropdown-item {
    display: block;
    width: 100%;
    padding: 11px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88em;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.profile-dropdown-item:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.profile-dropdown-logout {
    color: var(--danger);
}

.profile-dropdown-logout:hover {
    background: var(--surface-2);
    color: var(--danger);
}

.profile-signin-area {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---------------------------------------------------------------------------
   Main Container
   --------------------------------------------------------------------------- */
.container {
    max-width: 1040px;
    width: 100%;
    padding: 52px 40px;
    margin: 0 auto;
}

.header {
    margin-bottom: 36px;
}

.header h1 {
    font-size: 2em;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1em;
    margin-top: 6px;
}

/* ---------------------------------------------------------------------------
   Section Cards
   --------------------------------------------------------------------------- */
.section {
    padding: 24px 28px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.section h2 {
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Info Box
   --------------------------------------------------------------------------- */
.info-box {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-primary);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin: 20px 0;
}

.info-box strong {
    color: var(--text-primary);
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.info-box p {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Primary: white fill, black text */
.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
    border: 1px solid var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Secondary: transparent, white border */
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--accent-dim);
}

.btn-secondary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Status / Health Badge
   --------------------------------------------------------------------------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 28px;
}

.health-check {
    text-align: center;
    margin: 28px 0;
}

.health-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 8px;
    animation: pulse 2.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ---------------------------------------------------------------------------
   Content Grid
   --------------------------------------------------------------------------- */
.content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .content {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 40px 20px;
    }
}

/* ---------------------------------------------------------------------------
   API Endpoint Cards
   --------------------------------------------------------------------------- */
.endpoint {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.endpoint-method {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.75em;
    margin-right: 8px;
    color: #0a0a0a;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.method-get  { background: #e2e2e2; }
.method-post { background: var(--accent); }

.endpoint-path {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 0.85em;
    margin: 8px 0 4px;
}

.endpoint-desc {
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* ---------------------------------------------------------------------------
   Code Block
   --------------------------------------------------------------------------- */
.code-block {
    background: var(--surface-2);
    color: #e2e2e2;
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.83em;
    overflow-x: auto;
    margin: 10px 0;
    line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   iFrame container (Looker, etc.)
   --------------------------------------------------------------------------- */
.iframe-container {
    width: 100%;
    padding: 24px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 36px;
}

.iframe-container h2 {
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.iframe-container iframe {
    width: 100%;
    max-width: 100%;
    min-height: 600px;
    border-radius: var(--radius-sm);
    border: none;
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82em;
    padding-top: 32px;
    margin-top: 48px;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Forms — Inputs, Selects (shared across preferences, etc.)
   --------------------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 0.9em;
    transition: border-color 0.15s;
    width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-dim);
}

/* ---------------------------------------------------------------------------
   Table
   --------------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

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

tr:hover td {
    background: var(--surface-2);
}

/* ---------------------------------------------------------------------------
   Logo block (used on index)
   --------------------------------------------------------------------------- */
.logo {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 20px;
    font-weight: bold;
}

/* ---------------------------------------------------------------------------
   Sign-in Loading Overlay
   Shown site-wide while the backend verifies a Google credential.
   --------------------------------------------------------------------------- */
@keyframes cm-spin {
    to { transform: rotate(360deg); }
}

#signin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

#signin-overlay.visible {
    display: flex;
}

#signin-overlay-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    min-width: 220px;
}

#signin-overlay-spinner {
    width: 36px;
    height: 36px;
    border: 2.5px solid var(--border-light);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: cm-spin 0.75s linear infinite;
}

#signin-overlay-label {
    font-size: 0.92em;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
