/**
 * Unified Component Styles
 * Consistent design system for all pages
 */

/* ============================================
   COLOR SYSTEM - Gomag-inspired palette
   ============================================ */
:root {
    --primary: #ff6c37;      /* Orange - Main actions (Gomag accent) */
    --primary-hover: #e05a2a;
    --success: #10b981;      /* Green - Positive actions */
    --success-hover: #059669;
    --warning: #f59e0b;      /* Orange - Warning actions */
    --warning-hover: #d97706;
    --danger: #ef4444;       /* Red - Delete */
    --danger-hover: #dc2626;
    --secondary: #6b7280;    /* Gray - Secondary actions */
    --secondary-hover: #4b5563;
    --info: #3b82f6;         /* Blue - Info */
    --info-hover: #2563eb;

    /* Status colors */
    --status-new: #3b82f6;
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #6366f1;

    /* Typography - Gomag uses Inter font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title-section h2 {
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 2px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-title-section .subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============================================
   BUTTONS - UNIFIED SYSTEM (Skewed + Neobrutalism)
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-family);
    transform: skewX(-5deg);
}

.btn > * {
    display: inline-block;
    transform: skewX(5deg); /* Text back to normal */
}

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

/* Primary Button (Orange) - Main actions */
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--primary);
}

/* Success Button (Green) - Positive actions */
.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--success);
}

/* Warning Button (Orange) - Warning actions */
.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
    background: transparent;
    color: var(--warning);
    border-color: var(--warning);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--warning);
}

/* Danger Button (Red) - Delete actions */
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--danger);
}

/* Secondary Button (Gray) - Secondary actions */
.btn-secondary {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--secondary);
}

/* Outline Buttons */
.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover:not(:disabled) {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--primary);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
    transform: skewX(-5deg) translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--secondary);
}

/* Icon Buttons (small) */
.btn-icon {
    padding: 8px;
    font-size: 18px;
    min-width: auto;
    border-radius: 2px;
    transform: skewX(-5deg);
}

.btn-icon > * {
    transform: skewX(5deg);
}

/* Button sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* ============================================
   FILTERS & SEARCH BAR
   ============================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters-bar .search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.filters-bar .search-input::placeholder {
    color: var(--text-secondary);
}

.filters-bar select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

/* ============================================
   TABLES - UNIFIED STYLE
   ============================================ */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.data-table table {
    width: 100%;
    min-width: 900px; /* Force horizontal scroll on narrow screens */
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-hover);
}

.data-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

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

/* Table Actions Column */
.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-actions button {
    padding: 6px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    border-radius: 4px;
}

.table-actions button:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

/* ============================================
   BADGES - STATUS INDICATORS (Skewed + Neobrutalism)
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 2px;
    white-space: nowrap;
    transform: skewX(-3deg);
    border: 1px solid;
    transition: all 0.15s;
}

.badge > * {
    display: inline-block;
    transform: skewX(3deg); /* Counter-skew text */
}

.badge-primary {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.4);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.4);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
}

.badge-secondary {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.4);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.4);
}

/* Specific status badges */
.badge-new {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.4);
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.4);
}

.badge-inactive {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.4);
}

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 6px 0;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* Inline stats (smaller version) */
.stats-inline {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-inline {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.stat-inline .stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-inline .stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* ============================================
   CONTENT CARDS
   ============================================ */
.content-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.content-card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.content-card-body {
    padding: 20px;
}

/* Colored card variants */
.card-primary {
    border-left: 4px solid var(--primary);
}

.card-success {
    border-left: 4px solid var(--success);
}

.card-warning {
    border-left: 4px solid var(--warning);
}

.card-danger {
    border-left: 4px solid var(--danger);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 12px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        width: 100%;
        justify-content: stretch;
    }

    .page-actions .btn {
        flex: 1;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar .search-input {
        min-width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--info);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease-in forwards;
}

@media (max-width: 768px) {
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        min-width: auto;
    }
}

/* ============================================
   MOBILE GLOBAL FIXES - Prevent horizontal overflow
   ============================================ */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    body {
        position: relative;
    }

    /* Main content area */
    .main-content {
        padding: 15px !important;
        overflow-x: hidden;
    }

    /* Content cards */
    .content-card {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
    }

    .content-card-header,
    .content-card-body {
        padding: 15px;
    }

    /* Tables - ensure scroll container */
    .data-table {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    /* Buttons on mobile - reduce skew effect size */
    .btn {
        font-size: 13px;
        padding: 8px 12px;
        gap: 6px;
    }

    /* Stat cards - single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
    }

    /* Page title - smaller on mobile */
    .page-title-section h2 {
        font-size: 18px !important;
    }

    .page-title-section .subtitle {
        font-size: 13px;
    }

    /* Inline stats - wrap on mobile */
    .stats-inline {
        flex-direction: column;
        gap: 12px;
        padding: 12px 15px;
    }

    /* Badges - slightly smaller */
    .badge {
        padding: 4px 10px;
        font-size: 11px;
    }
}
