/* ================================================================
   Shared Components
   ================================================================ */

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-card .stat-change {
    font-size: var(--text-xs);
    font-weight: 500;
}

.stat-card .stat-change.positive { color: var(--green); }
.stat-card .stat-change.negative { color: var(--red); }

/* ---- Forms ---- */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-select {
    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='%238B95A8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

.form-inline {
    display: flex;
    gap: var(--sp-3);
    align-items: end;
}

.form-inline .form-input {
    flex: 1;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.badge-blue   { background: var(--accent-muted);  color: var(--accent); }
.badge-green  { background: var(--green-muted);   color: var(--green); }
.badge-orange { background: var(--orange-muted);  color: var(--orange); }
.badge-red    { background: var(--red-muted);     color: var(--red); }
.badge-purple { background: var(--purple-muted);  color: var(--purple); }

.ai-badge {
    background: linear-gradient(135deg, var(--purple), var(--accent));
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
}

/* ---- Tabs ---- */
.tab-nav {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-6);
    overflow-x: auto;
}

.tab-btn {
    padding: var(--sp-3) var(--sp-5);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    background: none;
    transition: all var(--dur-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-btn:hover:not(.active) {
    color: var(--text-secondary);
}

/* ---- Checkboxes ---- */
.item-check {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.item-check input[type=checkbox] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast);
    flex-shrink: 0;
}

.item-check input:checked + .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.item-check input:checked + .checkmark::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

/* ---- Empty & Error States ---- */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: var(--sp-12);
    font-size: var(--text-sm);
}

.empty-state svg {
    display: block;
    margin: 0 auto var(--sp-4);
    opacity: 0.3;
}

.empty-state h3 {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

.error-state {
    text-align: center;
    color: var(--red);
    padding: var(--sp-6);
    font-size: var(--text-sm);
    background: var(--red-muted);
    border-radius: var(--radius-md);
}

/* ---- Spinner ---- */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: var(--sp-8) auto;
}

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

/* ---- Lists ---- */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    transition: background var(--dur-fast);
    border-bottom: 1px solid var(--border);
}

.list-item:hover {
    background: rgba(128,128,128,0.04);
}

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

/* ---- Data Table ---- */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
    background: rgba(128,128,128,0.04);
}

/* ---- Progress Bar ---- */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width var(--dur-slow) var(--ease-out);
}

/* ---- Grid Utilities ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr; }
}

/* ---- User Avatar ---- */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-xs);
    flex-shrink: 0;
}

/* ---- Section Headers ---- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}

.section-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--sp-1);
}

/* ---- Color Dot ---- */
.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---- Divider ---- */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--sp-4) 0;
}

/* ---- Text Utilities ---- */
.text-muted { color: var(--text-muted); font-size: var(--text-sm); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.font-mono { font-family: var(--font-mono); }
