/**
 * Components CSS - Semantic component styles
 * Uses CSS variables defined in theme files
 * All components should work with any theme
 */

/* ============================================
   NAVIGATION COMPONENTS
   ============================================ */

/* Sidebar Navigation */
.sidebar {
    background: var(--sidebar-bg);
    padding: calc(var(--spacing-unit) * 2);
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
}

.sidebar-header {
    padding: calc(var(--spacing-unit) * 2);
    border-bottom: var(--sidebar-border);
}

.app-title {
    font-size: 1.75rem;
    font-weight: 900;
    color: var(--color-primary);
    letter-spacing: 0.5px;
    margin: 0;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--nav-gap, var(--spacing-unit));
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--nav-item-padding);
    background: var(--nav-item-bg);
    color: var(--nav-item-color);
    border-radius: var(--nav-item-radius);
    border: var(--nav-item-border);
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all var(--transition-speed);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--nav-item-hover-bg);
    color: var(--nav-item-hover-color);
    transform: var(--nav-item-hover-transform);
}

.nav-item.active {
    background: var(--nav-item-active-bg);
    color: var(--nav-item-active-color);
    box-shadow: var(--nav-item-active-shadow);
}

.nav-item-icon {
    margin-right: calc(var(--spacing-unit) * 1.5);
    font-size: 1.25rem;
}

/* Header */
.header {
    background: var(--header-bg);
    padding: calc(var(--spacing-unit) * 2);
    border-bottom: var(--header-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: var(--spacing-unit);
    align-items: center;
}

/* ============================================
   CARD COMPONENTS
   ============================================ */

.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    padding: calc(var(--spacing-unit) * 2);
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
    transform: var(--card-hover-transform);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    border-bottom: var(--card-header-border);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--card-title-color);
    margin: 0;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
}

.card-footer {
    margin-top: calc(var(--spacing-unit) * 1.5);
    padding-top: var(--spacing-unit);
    border-top: var(--card-footer-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Product Card Specific */
.product-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: var(--product-image-bg);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-unit);
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
    min-height: 2.8em;
}

.product-meta {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) / 2);
}

/* ============================================
   STAT COMPONENTS
   ============================================ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: calc(var(--spacing-unit) * 2);
}

.stat-panel {
    background: var(--stat-panel-bg);
    border-radius: var(--stat-panel-radius);
    border: var(--stat-panel-border);
    padding: calc(var(--spacing-unit) * 2);
    box-shadow: var(--stat-panel-shadow);
    position: relative;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--stat-label-color);
    margin-bottom: calc(var(--spacing-unit) / 2);
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--stat-value-color);
    line-height: 1;
}

.stat-change {
    font-size: 0.875rem;
    margin-top: calc(var(--spacing-unit) / 2);
}

.stat-change.positive {
    color: var(--color-success);
}

.stat-change.negative {
    color: var(--color-danger);
}

/* ============================================
   BADGE COMPONENTS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: calc(var(--spacing-unit) / 2) var(--spacing-unit);
    border-radius: var(--badge-radius);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--badge-bg);
    color: var(--badge-color);
    border: var(--badge-border);
}

.badge-success {
    background: var(--badge-success-bg);
    color: var(--badge-success-color);
}

.badge-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-color);
}

.badge-danger {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-color);
}

.badge-info {
    background: var(--badge-info-bg);
    color: var(--badge-info-color);
}

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--btn-padding);
    border-radius: var(--btn-radius);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: var(--btn-bg);
    color: var(--btn-color);
    border: var(--btn-border);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.btn:hover {
    background: var(--btn-hover-bg);
    color: var(--btn-hover-color);
    transform: var(--btn-hover-transform);
    box-shadow: var(--btn-hover-shadow);
}

.btn:active {
    transform: var(--btn-active-transform);
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-color);
}

.btn-primary:hover {
    background: var(--btn-primary-hover-bg);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-color);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover-bg);
}

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

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

.btn-sm {
    padding: calc(var(--spacing-unit) / 2) var(--spacing-unit);
    font-size: 0.8125rem;
}

.btn-lg {
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    font-size: 1.0625rem;
}

/* ============================================
   FORM COMPONENTS
   ============================================ */

.form-group {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) / 2);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--form-label-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    padding: var(--spacing-unit);
    border-radius: var(--form-input-radius);
    border: var(--form-input-border);
    background: var(--form-input-bg);
    color: var(--form-input-color);
    font-size: 0.9375rem;
    font-family: var(--font-primary);
    transition: all var(--transition-speed);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--form-input-focus-border);
    box-shadow: var(--form-input-focus-shadow);
}

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

.form-error {
    font-size: 0.8125rem;
    color: var(--color-danger);
    margin-top: calc(var(--spacing-unit) / 2);
}

/* ============================================
   FILTER COMPONENTS
   ============================================ */

.filter-bar {
    display: flex;
    gap: var(--spacing-unit);
    padding: calc(var(--spacing-unit) * 2);
    background: var(--filter-bar-bg);
    border-radius: var(--border-radius-md);
    margin-bottom: calc(var(--spacing-unit) * 2);
    flex-wrap: wrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: calc(var(--spacing-unit) / 2) calc(var(--spacing-unit) * 1.5);
    border-radius: var(--filter-chip-radius);
    background: var(--filter-chip-bg);
    color: var(--filter-chip-color);
    border: var(--filter-chip-border);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.filter-chip:hover {
    background: var(--filter-chip-hover-bg);
    transform: translateY(-2px);
}

.filter-chip.active {
    background: var(--filter-chip-active-bg);
    color: var(--filter-chip-active-color);
    box-shadow: var(--filter-chip-active-shadow);
}

/* ============================================
   PROGRESS COMPONENTS
   ============================================ */

.progress-bar {
    width: 100%;
    height: var(--progress-height, 8px);
    background: var(--progress-bg);
    border-radius: var(--progress-radius);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--progress-fill-bg);
    border-radius: var(--progress-radius);
    transition: width var(--transition-speed);
    position: relative;
}

.progress-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: calc(var(--spacing-unit) / 2);
    color: var(--color-text-muted);
}

/* ============================================
   STATUS INDICATOR
   ============================================ */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--spacing-unit) / 2);
    font-size: 0.875rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.status-indicator.online .status-dot {
    background: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.status-indicator.offline .status-dot {
    background: var(--color-danger);
}

.status-indicator.synced .status-dot {
    background: var(--color-info);
    box-shadow: 0 0 8px var(--color-info);
}

/* ============================================
   TABLE COMPONENTS
   ============================================ */

.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--table-bg);
    border-radius: var(--border-radius-md);
    box-shadow: var(--card-shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: calc(var(--spacing-unit) * 1.5);
    text-align: left;
    border-bottom: var(--table-border);
}

.table th {
    background: var(--table-header-bg);
    color: var(--table-header-color);
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--table-row-hover-bg);
}

/* ============================================
   MODAL/DIALOG
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-in;
}

.modal {
    background: var(--modal-bg);
    border-radius: var(--modal-radius);
    box-shadow: var(--modal-shadow);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    animation: slideInUp 0.3s ease-out;
}

.modal-header {
    padding: calc(var(--spacing-unit) * 2);
    border-bottom: var(--modal-border);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.modal-body {
    padding: calc(var(--spacing-unit) * 2);
}

.modal-footer {
    padding: calc(var(--spacing-unit) * 2);
    border-top: var(--modal-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-unit);
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.skeleton {
    background: var(--skeleton-bg);
    border-radius: var(--border-radius-sm);
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}
