/* ========================================
   Tradesbridge — Foundation Styles
   ======================================== */

:root {
    --color-bg: #f5f6fa;
    --color-surface: #ffffff;
    --color-border: #e2e5ec;
    --color-text: #1a1a2e;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-info: #0891b2;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 15px;
}

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

/* ---- Navbar ---- */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.nav-brand a {
    font-weight: 700;
    font-size: 18px;
    color: var(--color-text);
}
.nav-brand a:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
    padding: 6px 14px;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.nav-links a.active { background: var(--color-primary); color: white; }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-info { color: var(--color-text-muted); }

/* ---- Container ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ---- Page Header ---- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.subtitle { color: var(--color-text-muted); margin-top: 4px; font-size: 14px; }
.back-link { font-size: 13px; color: var(--color-text-muted); display: inline-block; margin-bottom: 8px; }

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--color-text-muted); }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

/* ---- Detail Grid ---- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; }

/* ---- Detail List ---- */
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.detail-list dt { color: var(--color-text-muted); font-weight: 500; }
.detail-list dd { word-break: break-word; }

/* ---- Section ---- */
.section { margin-bottom: 32px; }
.section h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 10px 14px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--color-border); }
.table th { background: var(--color-bg); font-weight: 600; color: var(--color-text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--color-bg);
    color: var(--color-text-muted);
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-onboarding { background: #dbeafe; color: #1e40af; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-paused { background: #fef3c7; color: #92400e; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-tier-starter { background: #e0e7ff; color: #3730a3; }
.badge-tier-growth { background: #d1fae5; color: #065f46; }
.badge-tier-pro { background: #fce7f3; color: #9d174d; }
.badge-priority-high { background: #fef3c7; color: #92400e; }
.badge-priority-urgent { background: #fee2e2; color: #991b1b; }

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.role-sysadmin { background: #1a1a2e; color: white; }
.role-account_manager { background: #7c3aed; color: white; }
.role-business_owner { background: #2563eb; color: white; }
.role-employee { background: #6b7280; color: white; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-full { width: 100%; text-align: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--color-text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group small { display: block; margin-top: 4px; font-size: 12px; color: var(--color-text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.inline-form { display: inline; }
.inline-controls { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.inline-controls select { width: auto; padding: 4px 8px; font-size: 13px; }

/* ---- Login ---- */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.login-card h1 { font-size: 28px; margin-bottom: 4px; }
.login-subtitle { color: var(--color-text-muted); margin-bottom: 24px; }
.login-card .form-group { text-align: left; }

/* ---- Flash Messages ---- */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: 0.6; }
.flash-close:hover { opacity: 1; }

/* ---- Business Cards (Manager view) ---- */
.business-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.business-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    color: var(--color-text);
    transition: box-shadow 0.15s, transform 0.15s;
}
.business-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.business-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.business-card-header h3 { font-size: 16px; }
.business-card-body { font-size: 14px; color: var(--color-text-muted); }
.business-card-body p { margin-bottom: 4px; }
.business-card-footer { margin-top: 12px; }

/* ---- Notifications (Business dashboard) ---- */
.notification-feed { display: flex; flex-direction: column; gap: 8px; }
.notification-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.notification-unread { border-left: 3px solid var(--color-primary); }
.notification-urgent { border-left-color: var(--color-danger); }
.notification-high { border-left-color: var(--color-warning); }
.notification-header { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.notification-time { font-size: 12px; color: var(--color-text-muted); margin-left: auto; }
.notification-body { font-size: 14px; }
.notification-body p { margin-top: 4px; color: var(--color-text-muted); }
.notification-actions { margin-top: 8px; }

/* ---- Utilities ---- */
.empty-state { color: var(--color-text-muted); font-style: italic; padding: 20px 0; }
.text-muted { color: var(--color-text-muted); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .navbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 8px; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; }
    .form-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .container { padding: 16px; }
}
