/**
 * Etchly Design System - CSS Variables
 * Single source of truth for all color and spacing variables
 * Import this file in all HTML pages to ensure consistency
 */

:root {
    /* ============================================
       BRAND COLORS - Etchly Identity
       ============================================ */
    --accent: #00A9E0;          /* Etchly Blue - Primary brand color */
    --accent-hover: #008cc0;    /* Etchly Blue - Hover state */
    --accent-light: #69d0ff;    /* Light blue for highlights */
    
    --warn: #F58220;            /* Etchly Orange - Secondary brand color */
    --warn-hover: #cc7000;      /* Orange hover state */
    --theme-orange: #FF8C00;    /* Theme orange for CTAs */
    
    /* ============================================
       SEMANTIC COLORS
       ============================================ */
    --success: #28a745;
    --success-hover: #218838;
    --danger: #dc3545;
    --danger-hover: #c82333;
    --info: #007bff;
    --info-hover: #0069d9;
    
    /* ============================================
       DARK MODE PALETTE (Default)
       ============================================ */
    --bg: #0b0e12;              /* Main background */
    --panel: #10151c;           /* Panel/card background */
    --muted: #9aa3b2;           /* Muted text */
    --hi: #f7fbff;              /* High contrast text (white) */
    --grid: #1f2631;            /* Grid lines, borders */
    --border: #2b3340;          /* Standard border */
    --border-hover: #3c4656;    /* Border hover state */
    
    /* ============================================
       LIGHT MODE PALETTE
       ============================================ */
    --light-bg: #e9ebf0;        /* Main background */
    --light-panel: #f7f7f9;     /* Panel/card background */
    --light-muted: #5b667a;     /* Muted text */
    --light-hi: #10151c;        /* High contrast text (dark) */
    --light-grid: #d8dade;      /* Grid lines, canvas bg */
    --light-border: #b6bcc4;    /* Standard border */
    --light-border-hover: #8c93a0; /* Border hover state */
    
    /* Alternative light mode naming */
    --main-bg: #FFFFFF;
    --content-text: #0b0e12;
    --card-bg: #FFFFFF;
    --card-border: #e0e0e0;
    
    /* ============================================
       STATUS COLORS (Orders, etc.)
       ============================================ */
    --status-new: #ff6384;
    --status-processing: #ffcd56;
    --status-shipped: #36a2eb;
    --status-complete: var(--success);
    
    /* ============================================
       SPECIAL COLORS
       ============================================ */
    --pink: #FF69B4;
    --admin-center: #FF00FF;
    --grouped-svg: #E91E63;
    
    /* ============================================
       SPACING & SIZING
       ============================================ */
    --header-height: 90px;
    --ruler-size: 30px;
    --sidebar-width: 340px;
    --border-radius: 12px;
    --border-radius-sm: 6px;
    --border-radius-lg: 16px;
    
    /* ============================================
       TRANSITIONS
       ============================================ */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* ============================================
       SHADOWS
       ============================================ */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5);
    
    /* ============================================
       TYPOGRAPHY
       ============================================ */
    --font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    --font-size-base: 14px;
    --line-height-base: 1.4;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font: var(--font-size-base)/var(--line-height-base) var(--font-family);
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* ============================================
   LIGHT MODE OVERRIDES
   Applied when body has .light-mode class
   ============================================ */
body.light-mode {
    background: var(--light-bg);
    color: var(--light-hi);
}

body.light-mode header {
    background: linear-gradient(180deg, var(--light-panel), var(--light-bg));
    border-bottom: 1px solid var(--light-border);
}

body.light-mode .btn {
    border: 1px solid var(--light-border);
    background: var(--light-panel);
    color: var(--light-hi);
}

body.light-mode .btn:hover {
    border-color: var(--light-border-hover);
}

/* ============================================
   DARK MODE STYLES
   Applied when body has .dark-mode class
   ============================================ */
body.dark-mode {
    background: var(--bg);
    color: var(--hi);
}

body.dark-mode header {
    background: linear-gradient(180deg, var(--panel), var(--bg));
    border-bottom: 1px solid var(--grid);
}

/* ============================================
   COMMON BUTTON STYLES
   ============================================ */
.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--hi);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

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

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

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--border-radius-sm);
}

/* Primary button (Orange CTA) */
.btn-primary {
    background: var(--theme-orange);
    border-color: var(--theme-orange);
    color: var(--hi);
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--warn-hover);
    border-color: var(--warn-hover);
}

/* Secondary button (Blue) */
.btn-secondary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--hi);
    font-weight: 700;
}

.btn-secondary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Success button (Green) */
.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: var(--hi);
    font-weight: 700;
}

.btn-success:hover {
    background: var(--success-hover);
    border-color: var(--success-hover);
}

/* Danger button (Red) */
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--hi);
    font-weight: 700;
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* ============================================
   COMMON HEADER STYLES
   ============================================ */
header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--light-panel), var(--light-bg));
    border-bottom: 1px solid var(--light-border);
    box-shadow: var(--shadow-md);
    transition: background var(--transition-normal), border-bottom var(--transition-normal);
    z-index: 999;
}

header .brand {
    display: flex;
    align-items: center;
}

header .brand a {
    display: flex;
    align-items: center;
}

header .brand img {
    height: 68px;
    width: auto;
    border-radius: 8px;
    object-fit: contain;
}

header .btns {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

/* ============================================
   ACCOUNT MENU STYLES
   ============================================ */
.account-menu-container {
    position: relative;
    display: inline-block;
}

#accountMenu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: var(--panel);
    border: 1px solid var(--grid);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 200px;
    padding: 8px 0;
}

.account-menu-item {
    display: block;
    padding: 10px 15px;
    color: var(--hi);
    text-decoration: none;
    cursor: pointer;
}

.account-menu-item:hover {
    background: var(--grid);
}

#signOutMenuItem {
    color: var(--danger);
    border-top: 1px solid var(--grid);
    margin-top: 5px;
    padding-top: 10px;
}

#signOutMenuItem:hover {
    background: #250f11;
}

#userAvatarContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background: var(--panel);
    cursor: pointer;
}

#headerAvatar {
    height: 38px;
    width: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

#userAvatarContainer:hover #headerAvatar {
    border-color: var(--warn);
}

/* Light mode account menu */
body.light-mode #accountMenu {
    background: var(--light-panel);
    border: 1px solid var(--light-border);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

body.light-mode .account-menu-item {
    color: var(--light-hi);
}

body.light-mode .account-menu-item:hover {
    background: var(--light-grid);
}

body.light-mode #signOutMenuItem {
    border-top: 1px solid var(--light-border);
}

body.light-mode #signOutMenuItem:hover {
    background: #fcebeb;
}

body.light-mode #userAvatarContainer {
    background: var(--light-panel);
}

/* ============================================
   THEME SWITCH STYLES
   ============================================ */
.theme-switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    color: var(--muted);
    border-top: 1px solid var(--grid);
    margin-top: 5px;
    padding-top: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3c4656;
    transition: var(--transition-normal);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: var(--hi);
    transition: var(--transition-normal);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

body.light-mode .theme-switch-container {
    color: var(--light-muted);
    border-top: 1px solid var(--light-border);
}

body.light-mode .slider {
    background-color: var(--light-border);
}

body.light-mode .slider:before {
    background-color: var(--light-hi);
}

/* ============================================
   FORM INPUT STYLES
   ============================================ */
input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
input[type="number"],
select,
textarea {
    background: var(--panel);
    color: var(--hi);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 8px 10px;
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

body.light-mode input[type="email"],
body.light-mode input[type="password"],
body.light-mode input[type="text"],
body.light-mode input[type="tel"],
body.light-mode input[type="number"],
body.light-mode select,
body.light-mode textarea {
    background: var(--light-panel);
    color: var(--light-hi);
    border: 1px solid var(--light-border);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.subtle {
    color: var(--muted);
}

body.light-mode .subtle {
    color: var(--light-muted);
}

.hidden {
    display: none !important;
}

.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; }
