/* Global CSS Utilities and Common Components */

/* ===== Card Components ===== */
.card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.card-lg {
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.card-hover {
    transition: transform 0.3s, box-shadow 0.3s;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* ===== Grid Utilities ===== */
.grid {
    display: grid;
    gap: 2rem;
}

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-auto-sm {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ===== Typography Utilities ===== */
.text-light { color: var(--text-light); }
.text-dark { color: var(--text-dark); }
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-danger { color: #dc2626; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.fs-sm { font-size: 0.875rem; }
.fs-lg { font-size: 1.125rem; }
.fs-xl { font-size: 1.25rem; }

/* ===== Spacing Utilities ===== */
/* Margins */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

.my-1 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-2 { margin-top: 1rem; margin-bottom: 1rem; }
.my-3 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.my-4 { margin-top: 2rem; margin-bottom: 2rem; }

.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.p-5 { padding: 3rem; }

.py-1 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2 { padding-top: 1rem; padding-bottom: 1rem; }
.py-3 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-4 { padding-top: 2rem; padding-bottom: 2rem; }

.px-1 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-2 { padding-left: 1rem; padding-right: 1rem; }
.px-3 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-4 { padding-left: 2rem; padding-right: 2rem; }

/* ===== Container Utilities ===== */
.container-sm { max-width: 700px; margin: 0 auto; }
.container-md { max-width: 800px; margin: 0 auto; }
.container-lg { max-width: 900px; margin: 0 auto; }
.container-xl { max-width: 1200px; margin: 0 auto; }

/* ===== Alert/Notice Components ===== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: 1px solid;
}

.alert-warning {
    background: #fef3c7;
    border-color: #fbbf24;
    color: #92400e;
}

.alert-info {
    background: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-base);
}

.alert-success {
    background: #f0fdf4;
    border-color: var(--secondary-color);
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #7f1d1d;
}

/* ===== Table Styles ===== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-alt);
    font-weight: 600;
}

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

.table-responsive {
    overflow-x: auto;
}

/* ===== Form Utilities ===== */
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-note {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* ===== Border Radius Utilities ===== */
.rounded { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-full { border-radius: 50%; }
.rounded-pill { border-radius: 20px; }

/* ===== Background Utilities ===== */
.bg-white { background: var(--white); }
.bg-light { background: var(--bg-light); }
.bg-alt { background: var(--bg-alt); }
.bg-primary { background: var(--primary-color); }
.bg-secondary { background: var(--secondary-color); }

/* ===== Border Utilities ===== */
.border { border: 1px solid var(--border-color); }
.border-primary { border: 1px solid var(--primary-color); }
.border-secondary { border: 1px solid var(--secondary-color); }
.border-2 { border-width: 2px; }

/* ===== Shadow Utilities ===== */
.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* ===== Transition Utilities ===== */
.transition-all { transition: all 0.3s; }
.transition-colors { transition: color 0.3s, background-color 0.3s, border-color 0.3s; }
.transition-transform { transition: transform 0.3s; }
.transition-opacity { transition: opacity 0.3s; }

/* ===== Display Utilities ===== */
.d-none { display: none; }
.d-block { display: block; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* ===== Width Utilities ===== */
.w-100 { width: 100%; }
.w-auto { width: auto; }

/* ===== List Utilities ===== */
.list-none { list-style: none; padding: 0; }

/* ===== Responsive Utilities ===== */
@media (max-width: 768px) {
    .mobile-hide { display: none; }
    .mobile-show { display: block; }
    .mobile-1col { grid-template-columns: 1fr !important; }
    .mobile-text-center { text-align: center; }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .desktop-hide { display: none; }
    .desktop-show { display: block; }
}

/* ===== Utility Overrides ===== */
.no-margin { margin: 0 !important; }
.no-padding { padding: 0 !important; }
.full-width { width: 100% !important; }

/* ===== Arrow Indicators ===== */
.arrow-up, .arrow-down {
    font-weight: bold;
    font-size: 1.1em;
    cursor: help;
    position: relative;
    display: inline-block;
    padding: 0 2px;
    text-decoration: none !important;
}

.arrow-up {
    color: #16a34a; /* Green for increase/upregulate */
}

.arrow-down {
    color: #dc2626; /* Red for decrease/downregulate */
}

/* Arrow tooltips without underline */
.arrow-up.tooltip,
.arrow-down.tooltip {
    text-decoration: none !important;
    text-decoration-style: none !important;
}

/* ===== Tooltips ===== */
.tooltip {
    position: relative;
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    text-decoration-color: var(--primary-color);
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1rem;
    background: white;
    color: var(--text-dark);
    font-size: 0.875rem;
    font-weight: normal;
    white-space: normal;
    min-width: 200px;
    max-width: 300px;
    text-align: center;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    margin-bottom: 8px;
    z-index: 9999;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    margin-bottom: 2px;
    z-index: 10000;
}

/* Disabled - using JavaScript tooltips instead
.tooltip:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

.tooltip:hover::after {
    opacity: 1;
}
*/

/* Responsive tooltip positioning */
@media (max-width: 768px) {
    .tooltip::before {
        left: 0;
        transform: translateX(0);
        margin-left: -20px;
    }
    
    .tooltip:hover::before {
        transform: translateX(0) translateY(-2px);
    }
    
    .tooltip::after {
        left: 30px;
        transform: translateX(0);
    }
}

