/**
 * Generic Components Color System
 * All forms, inputs, tabs, cards, and components use these generic colors
 * Dynamic colors are ONLY used for buttons (preserved in base.html.twig)
 */

/* ========================================
   COLOR PALETTE - Generic & Universal
   ======================================== */

:root {
    /* Primary Colors - Neutral & Professional */
    --component-primary: #2c3e50;        /* Dark slate for text/borders */
    --component-secondary: #34495e;      /* Medium slate for accents */
    --component-tertiary: #7f8c8d;       /* Light slate for muted text */
    
    /* Backgrounds */
    --bg-white: #ffffff;                 /* Pure white */
    --bg-light: #f5f5f5;                 /* Light gray background */
    --bg-lighter: #fafafa;               /* Lighter gray */
    --bg-card: #ffffff;                  /* Card backgrounds */
    
    /* Borders */
    --border-light: #e0e0e0;             /* Light borders */
    --border-medium: #d0d0d0;            /* Medium borders */
    --border-dark: #636363;              /* Dark borders */
    
    /* Text Colors */
    --text-primary: #2c3e50;             /* Primary text */
    --text-secondary: #7f8c8d;           /* Secondary text */
    --text-muted: #95a5a6;               /* Muted text */
    --text-light: #bdc3c7;               /* Light text */
    
    /* State Colors - Generic */
    --success: #27ae60;                  /* Green for success */
    --danger: #e74c3c;                   /* Red for danger */
    --warning: #f39c12;                  /* Orange for warning */
    --info: #3498db;                     /* Blue for info */
    
    /* Input States */
    --input-border: #d0d0d0;             /* Default input border */
    --input-border-focus: #3498db;       /* Focused input border */
    --input-border-error: #e74c3c;       /* Error input border */
    --input-bg: #ffffff;                 /* Input background */
    --input-disabled-bg: #ecf0f1;        /* Disabled input background */
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ========================================
   FORM ELEMENTS - Generic Styling
   ======================================== */

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group label.required::after {
    content: ' *';
    color: var(--danger);
}

/* Form Controls - Inputs, Selects, Textareas */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
select,
textarea {
    border: 1px solid var(--input-border) !important;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--input-border-focus) !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
    outline: none;
}

.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--input-disabled-bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--input-border-error) !important;
}

/* Placeholder */
::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ========================================
   CHECKBOXES & RADIOS
   ======================================== */

.md-checkbox input[type="checkbox"],
.md-radio input[type="radio"] {
    position: relative;
}

.md-checkbox label,
.md-radio label {
    color: var(--text-primary);
    cursor: pointer;
}

.md-checkbox input[type="checkbox"]:checked + label::before {
    border-color: var(--success);
    background-color: var(--success);
}

.md-radio input[type="radio"]:checked + label::before {
    border-color: var(--info);
    background-color: var(--info);
}

/* ========================================
   CARDS & PANELS - iOS Grouped Style
   ======================================== */

.card,
.panel,
.portlet {
    background-color: var(--ios-bg-grouped-secondary, #FFFFFF);
    border: none;
    border-radius: var(--ios-radius-lg, 14px);
    box-shadow: var(--ios-shadow-card, 0 1px 3px rgba(0,0,0,0.08));
    margin-bottom: var(--ios-space-4, 16px);
    overflow: hidden;
}

.card-header,
.panel-heading,
.portlet-title {
    background-color: transparent;
    border-bottom: 1px solid var(--ios-separator, rgba(60, 60, 67, 0.12));
    padding: var(--ios-space-4, 16px);
    color: var(--ios-label, #000000);
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, sans-serif);
    font-weight: var(--ios-font-semibold, 600);
    font-size: var(--ios-text-md, 17px);
}

.card-body,
.panel-body,
.portlet-body {
    padding: 1.25rem;
}

.card-footer,
.panel-footer {
    background-color: var(--bg-lighter);
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
}

/* ========================================
   TABLES
   Modern table styles are now in modern-tables.css
   Keep minimal compatibility styles here
   ======================================== */

/* Compatibility with legacy table styles */
.table {
    color: var(--text-primary);
}

.table thead th {
    color: var(--text-primary);
}

.table tbody td {
    color: var(--text-primary);
}

/* ========================================
   TABS & NAVIGATION - iOS Style
   ======================================== */

/* Container wrapper for tabs matching conta style */
.nav-tabs-container {
    background: var(--color-card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    margin-bottom: 2rem;
}

.nav-tabs-container .nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border-light, #e2e8f0);
    background-color: var(--color-bg-secondary, #f8f9fa);
    margin-bottom: 0;
}

.nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border-light, #e2e8f0);
    background-color: var(--color-bg-secondary, #f8f9fa);
}

.nav-tabs > li {
    flex: 1;
    min-width: 0;
}

.nav-tabs > li > a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-text-muted, #64748b);
    border: none;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    background: transparent;
    min-width: 0;
}

/* Truncate tab labels with ellipsis when space is limited */
.nav-tabs-container .nav-tabs .nav-link {
    min-width: 0;
}
.nav-tabs-container .nav-tabs .hora-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 0%;
}

.nav-tabs > li > a:hover {
    background-color: rgba(var(--primary-color-rgb), 0.05);
    border-color: transparent;
    color: var(--primary-color, #0d6efd);
}

.nav-tabs > li > a:hover i {
    color: var(--primary-color, #0d6efd);
}

.nav-tabs > li.active > a,
.nav-tabs > li.active > a:focus,
.nav-tabs > li.active > a:hover {
    color: var(--primary-color, #0d6efd) !important;
    background-color: var(--color-card-bg, #ffffff);
    border: none;
    border-bottom: 3px solid var(--primary-color, #0d6efd);
    font-weight: 600;
}

.nav-tabs > li.active > a i,
.nav-tabs > li.active > a:focus i,
.nav-tabs > li.active > a:hover i {
    color: var(--primary-color, #0d6efd) !important;
}

.nav-pills {
    display: inline-flex;
    background-color: var(--ios-fill-secondary, rgba(120, 120, 128, 0.16));
    border-radius: var(--ios-radius-md, 10px);
    padding: 2px;
}

.nav-pills > li > a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-label, #000000);
    border-radius: calc(var(--ios-radius-md, 10px) - 2px);
    padding: var(--ios-space-2, 8px) var(--ios-space-4, 16px);
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: var(--ios-text-sm, 13px);
    font-weight: var(--ios-font-medium, 500);
    text-decoration: none;
    transition: all var(--ios-duration-normal, 0.3s) var(--ios-ease, ease);
}

.nav-pills > li > a:hover {
    background-color: transparent;
    color: var(--ios-label, #000000);
}

.nav-pills > li.active > a,
.nav-pills > li.active > a:focus,
.nav-pills > li.active > a:hover {
    background-color: var(--ios-bg-primary, #FFFFFF);
    box-shadow: var(--ios-shadow-segmented, 0 3px 8px rgba(0,0,0,0.12));
    color: var(--ios-label, #000000);
    color: var(--bg-white);
}

/* ========================================
   BADGES & LABELS - iOS Pill Style
   ======================================== */

.badge,
.label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--ios-space-1, 4px) var(--ios-space-3, 12px);
    min-height: 22px;
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif);
    font-size: var(--ios-text-xs, 11px);
    font-weight: var(--ios-font-semibold, 600);
    line-height: 1;
    border-radius: var(--ios-radius-pill, 9999px);
    white-space: nowrap;
    transition: all var(--ios-duration-fast, 0.2s) var(--ios-ease, ease);
}

.badge-default,
.label-default {
    background-color: var(--ios-gray-5, #E5E5EA);
    color: var(--ios-label-secondary, rgba(60, 60, 67, 0.6));
}

.badge-primary,
.label-primary {
    background-color: var(--ios-blue, #007AFF);
    color: #FFFFFF;
}

.badge-success,
.label-success {
    background-color: var(--ios-green, #34C759);
    color: #FFFFFF;
}

.badge-danger,
.label-danger {
    background-color: var(--ios-red, #FF3B30);
    color: #FFFFFF;
}

.badge-warning,
.label-warning {
    background-color: var(--ios-orange, #FF9500);
    color: #FFFFFF;
}

.badge-info,
.label-info {
    background-color: var(--ios-teal, #5AC8FA);
    color: #FFFFFF;
}

/* Soft/Subtle Badge Variants */
.badge-soft-primary,
.label-soft-primary {
    background-color: rgba(0, 122, 255, 0.15);
    color: var(--ios-blue, #007AFF);
}

.badge-soft-success,
.label-soft-success {
    background-color: rgba(52, 199, 89, 0.15);
    color: var(--ios-green, #34C759);
}

.badge-soft-danger,
.label-soft-danger {
    background-color: rgba(255, 59, 48, 0.15);
    color: var(--ios-red, #FF3B30);
}

.badge-soft-warning,
.label-soft-warning {
    background-color: rgba(255, 149, 0, 0.15);
    color: var(--ios-orange, #FF9500);
}

.badge-soft-info,
.label-soft-info {
    background-color: rgba(90, 200, 250, 0.15);
    color: var(--ios-teal, #5AC8FA);
}

/* Badge Sizes */
.badge-sm,
.label-sm {
    padding: 2px var(--ios-space-2, 8px);
    min-height: 18px;
    font-size: 10px;
}

.badge-lg,
.label-lg {
    padding: var(--ios-space-2, 8px) var(--ios-space-4, 16px);
    min-height: 28px;
    font-size: var(--ios-text-sm, 13px);
}

/* Notification Dot */
.badge-dot {
    width: 10px;
    height: 10px;
    min-height: auto;
    padding: 0;
    border-radius: 50%;
    background-color: var(--ios-red, #FF3B30);
}

/* ========================================
   ALERTS & NOTIFICATIONS - iOS Style
   ======================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--ios-space-3, 12px);
    padding: var(--ios-space-4, 16px);
    border-radius: var(--ios-radius-lg, 14px);
    border: none;
    margin-bottom: var(--ios-space-4, 16px);
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: var(--ios-text-base, 15px);
    line-height: 1.4;
    box-shadow: var(--ios-shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

.alert-success {
    background-color: rgba(52, 199, 89, 0.12);
    color: var(--ios-green-dark, #248A3D);
}

.alert-danger,
.alert-error {
    background-color: rgba(255, 59, 48, 0.12);
    color: var(--ios-red-dark, #D70015);
}

.alert-warning {
    background-color: rgba(255, 149, 0, 0.12);
    color: var(--ios-orange-dark, #C93400);
}

.alert-info {
    background-color: rgba(0, 122, 255, 0.12);
    color: var(--ios-blue-dark, #0051D5);
}

/* Alert text content - responsive wrapping */
.alert-text,
.alert > *:not(.fa):not(i):not(.close):not(.alert-close):not(.alert-icon):not(.alert-text) {
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal; /* Prefer breaking at word boundaries for Portuguese */
    hyphens: auto; /* Enable hyphenation if supported */
    line-height: 1.5;
}

/* Alert text wrapper - handles text nodes */
.alert-text {
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    line-height: 1.5;
}

/* Alert links - prevent awkward breaks in link text */
.alert a {
    display: inline;
    white-space: nowrap; /* Prevent link text from breaking on normal screens */
    word-break: keep-all;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.alert a:hover {
    opacity: 0.8;
}

/* Plan upgrade alert - link on own line for responsive visibility */
.alert--plan-upgrade .alert__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert--plan-upgrade .alert-link--block {
    display: inline-block;
    margin-top: 0.25rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Alert responsive adjustments */
@media (max-width: 768px) {
    .alert {
        padding: 12px;
        font-size: 14px;
        gap: 10px;
    }
    
    .alert > i:first-child,
    .alert > .fa:first-child {
        font-size: 16px;
        margin-top: 1px;
    }
    
    .alert-text {
        font-size: 14px;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .alert {
        padding: 10px;
        font-size: 13px;
        gap: 8px;
    }
    
    .alert > i:first-child,
    .alert > .fa:first-child {
        font-size: 14px;
    }
    
    .alert-text {
        font-size: 13px;
        line-height: 1.5;
    }
    
    /* Allow links to wrap on very small screens if needed, but try to keep them together */
    .alert a {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: normal; /* Prefer breaking at word boundaries in Portuguese */
        /* Break long words only if absolutely necessary */
        hyphens: auto;
    }
}

/* Alert with icon */
.alert .alert-icon,
.alert > i:first-child,
.alert > .fa:first-child {
    flex-shrink: 0;
    font-size: 18px;
    margin-top: 2px;
}

/* Alert close button */
.alert .close,
.alert .alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    padding: 0;
    font-size: 18px;
    transition: opacity var(--ios-duration-fast, 0.2s) ease;
}

.alert .close:hover,
.alert .alert-close:hover {
    opacity: 1;
}

/* ========================================
   PROGRESS BARS - iOS Thin Style
   ======================================== */

.progress {
    width: 100%;
    height: 4px;
    background-color: var(--ios-fill-secondary, rgba(120, 120, 128, 0.16));
    border-radius: var(--ios-radius-pill, 9999px);
    overflow: hidden;
    box-shadow: none;
}

.progress-bar {
    background-color: var(--ios-blue, #007AFF);
    color: transparent;
    height: 100%;
    border-radius: var(--ios-radius-pill, 9999px);
    transition: width var(--ios-duration-normal, 0.3s) var(--ios-ease, ease);
    line-height: 1;
    text-align: center;
    transition: width 0.6s ease;
}

.progress-bar-success {
    background-color: var(--success);
}

.progress-bar-danger {
    background-color: var(--danger);
}

.progress-bar-warning {
    background-color: var(--warning);
}

/* ========================================
   MODALS & OVERLAYS
   ======================================== */

.modal-content {
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background-color: var(--bg-lighter);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
}

.modal-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.25rem;
    color: var(--text-primary);
}

.modal-footer {
    background-color: var(--bg-lighter);
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
}

/* ========================================
   DROPDOWNS
   ======================================== */

.dropdown-menu {
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
}

.dropdown-menu > li > a {
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    transition: background-color 0.2s ease;
}

.dropdown-menu > li > a:hover {
    background-color: var(--bg-lighter);
    color: var(--text-primary);
}

.dropdown-menu > li.active > a {
    background-color: var(--component-primary);
    color: var(--bg-white);
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination > li > a,
.pagination > li > span {
    color: var(--text-primary);
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

.pagination > li > a:hover {
    background-color: var(--bg-lighter);
    border-color: var(--border-medium);
}

.pagination > li.disabled > a,
.pagination > li.disabled > span {
    color: var(--text-muted);
    background-color: var(--bg-lighter);
    cursor: not-allowed;
}

/* ========================================
   BREADCRUMBS
   ======================================== */

.breadcrumb {
    background-color: var(--bg-lighter);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.breadcrumb > li {
    color: var(--text-secondary);
}

.breadcrumb > li + li::before {
    color: var(--text-muted);
    content: "/";
    padding: 0 0.5rem;
}

.breadcrumb > li > a {
    color: var(--info);
    text-decoration: none;
}

.breadcrumb > li > a:hover {
    color: var(--component-primary);
    text-decoration: underline;
}

.breadcrumb > .active {
    color: var(--text-primary);
    font-weight: 500;
}

/* ========================================
   LIST GROUPS
   ======================================== */

.list-group {
    border: 1px solid var(--border-light);
    border-radius: 4px;
}

.list-group-item {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
}

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

.list-group-item:hover {
    background-color: var(--bg-lighter);
}

.list-group-item.active {
    background-color: var(--component-primary);
    border-color: var(--component-primary);
    color: var(--bg-white);
}

/* ========================================
   WELLS & JUMBOTRONS
   ======================================== */

.well,
.jumbotron {
    background-color: var(--bg-lighter);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ========================================
   TOOLTIPS & POPOVERS - iOS Style
   ======================================== */

.tooltip-inner {
    background-color: rgba(50, 50, 50, 0.95);
    color: #FFFFFF;
    padding: var(--ios-space-2, 8px) var(--ios-space-3, 12px);
    border-radius: var(--ios-radius-md, 10px);
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: var(--ios-text-sm, 13px);
    font-weight: var(--ios-font-medium, 500);
    max-width: 250px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--ios-shadow-popover, 0 10px 40px rgba(0,0,0,0.15));
}

.tooltip.top .tooltip-arrow,
.tooltip.bottom .tooltip-arrow {
    border-top-color: rgba(50, 50, 50, 0.95);
    border-bottom-color: rgba(50, 50, 50, 0.95);
}

.popover {
    background-color: var(--ios-bg-secondary, #F2F2F7);
    border: none;
    border-radius: var(--ios-radius-lg, 14px);
    box-shadow: var(--ios-shadow-popover, 0 10px 40px rgba(0,0,0,0.15));
    font-family: var(--ios-font-family, -apple-system, BlinkMacSystemFont, sans-serif);
}

.popover-title {
    background-color: transparent;
    border-bottom: 1px solid var(--ios-separator, rgba(60, 60, 67, 0.12));
    color: var(--ios-label, #000000);
    font-weight: var(--ios-font-semibold, 600);
    font-size: var(--ios-text-base, 15px);
    padding: var(--ios-space-3, 12px) var(--ios-space-4, 16px);
}

.popover-content {
    padding: var(--ios-space-3, 12px) var(--ios-space-4, 16px);
    color: var(--ios-label, #000000);
    font-size: var(--ios-text-sm, 13px);
}

/* ========================================
   HELPER CLASSES
   ======================================== */

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--component-primary) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-info {
    color: var(--info) !important;
}

.bg-light {
    background-color: var(--bg-light) !important;
}

.bg-white {
    background-color: var(--bg-white) !important;
}

.border-light {
    border-color: var(--border-light) !important;
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 768px) {
    .form-control,
    input,
    select,
    textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .card,
    .panel {
        margin-bottom: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .form-control,
    input,
    select,
    textarea {
        border: 1px solid #000 !important;
    }
    
    .card,
    .panel {
        border: 1px solid #000;
        box-shadow: none;
    }
}
