/* =========================================
   KREVIA - Components
   ========================================= */

/* CARDS */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.25rem; transition: var(--transition); }
.card:hover { border-color: var(--border-light); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.card-value { font-size: 2rem; font-weight: 800; }
.card-label { font-size: .8rem; color: var(--text-secondary); margin-top: .25rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { cursor: pointer; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.2rem; border-radius: var(--radius-md); font-size: .875rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: var(--transition); border: none; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer; transition: var(--transition); }
.btn-icon:hover { color: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; justify-content: center; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .5px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: .65rem .9rem; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: .9rem; transition: var(--transition); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem; border-radius: 20px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-gray { background: var(--gray-light); color: var(--gray); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.priority-alta { border-left: 3px solid var(--red); }
.priority-media { border-left: 3px solid var(--yellow); }
.priority-baixa { border-left: 3px solid var(--green); }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.section { margin-bottom: 2rem; }
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }

/* KANBAN */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; min-height: 400px; }
.kanban-column { min-width: 280px; max-width: 320px; flex-shrink: 0; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.kanban-column-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; font-size: .85rem; font-weight: 700; }
.kanban-count { background: var(--bg-tertiary); padding: .15rem .5rem; border-radius: 10px; font-size: .75rem; font-weight: 600; }
.kanban-cards { flex: 1; padding: .5rem; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; min-height: 100px; }
.kanban-cards.drag-over { background: var(--accent-light); border-radius: var(--radius-md); }
.kanban-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: .75rem; cursor: grab; transition: var(--transition); }
.kanban-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.kanban-card-title { font-size: .85rem; font-weight: 600; margin-bottom: .4rem; }
.kanban-card-meta { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .75rem; color: var(--text-muted); }

/* TABLE */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--bg-secondary); padding: .75rem 1rem; text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); white-space: nowrap; cursor: pointer; user-select: none; }
.data-table th:hover { color: var(--accent); }
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border-color); font-size: .85rem; vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .actions-cell { white-space: nowrap; display: flex; gap: .25rem; }

/* FILTERS */
.filters-bar { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; align-items: center; }
.filter-group { display: flex; align-items: center; gap: .35rem; }
.filter-group label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.filter-select { padding: .4rem .6rem; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: .8rem; font-family: inherit; }
.search-input { padding: .5rem .75rem .5rem 2rem; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: .85rem; min-width: 200px; font-family: inherit; }
.search-input:focus { outline: none; border-color: var(--accent); }
.search-wrapper { position: relative; }
.search-wrapper i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.view-toggle { display: flex; gap: 2px; background: var(--bg-tertiary); border-radius: var(--radius-md); padding: 3px; }
.view-toggle-btn { padding: .4rem .8rem; border: none; background: transparent; color: var(--text-secondary); font-size: .8rem; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); transition: var(--transition); font-family: inherit; }
.view-toggle-btn.active { background: var(--accent); color: var(--accent-text); }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.hidden { display: none; }
.modal-container { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); width: 100%; max-width: 700px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1rem; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--red); background: var(--red-light); }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border-color); display: flex; gap: .5rem; justify-content: flex-end; }
.modal-footer.hidden { display: none; }

/* TOAST */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 3000; display: flex; flex-direction: column-reverse; gap: .5rem; }
.toast { padding: .75rem 1rem; border-radius: var(--radius-md); font-size: .85rem; font-weight: 500; color: white; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: .5rem; max-width: 350px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--orange); }
.toast.info { background: var(--blue); }

/* LOADING / EMPTY */
.loading-spinner { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: .95rem; }

/* TABS */
.tabs { display: flex; gap: 2px; margin-bottom: 1.5rem; overflow-x: auto; }
.tab-btn { padding: .6rem 1rem; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary); font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: var(--transition); font-family: inherit; }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ALERTS */
.alert { padding: .75rem 1rem; border-radius: var(--radius-md); font-size: .85rem; display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.alert-warning { background: var(--yellow-light); color: var(--yellow); border: 1px solid rgba(234, 179, 8, .3); }
.alert-danger { background: var(--red-light); color: var(--red); border: 1px solid rgba(239, 68, 68, .3); }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid rgba(59, 130, 246, .3); }

/* SETTINGS */
.settings-section { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.5rem; }
.settings-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: .5rem; }

/* PRODUCT MANAGEMENT */
.product-mgmt-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; transition: var(--transition); }
.product-mgmt-card:hover { border-color: var(--border-light); }
.product-mgmt-name { font-weight: 600; font-size: .9rem; }
.product-mgmt-actions { display: flex; gap: .25rem; }

/* PROVIDER CARDS */
.provider-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: .75rem; transition: var(--transition); }
.provider-card:hover { border-color: var(--border-light); }
.provider-card.provider-default { border-color: var(--green); background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), var(--bg-card)); }
.provider-card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.provider-name { font-weight: 700; font-size: 1rem; }
.provider-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.provider-card-details { display: flex; gap: 1.25rem; font-size: .83rem; color: var(--text-secondary); }
.provider-card-details i { margin-right: .3rem; color: var(--text-muted); }
.provider-test-result { margin-top: .5rem; min-height: 0; }

/* CUSTOM DURATION INPUT */
.custom-duration-wrap { display: none; margin-top: .5rem; }
.custom-duration-wrap.visible { display: flex; gap: .5rem; align-items: center; }
.custom-duration-wrap input { width: 80px; }

/* QUICK INPUT BAR */
.quick-input-bar { display: flex; gap: .75rem; margin-bottom: 1.5rem; align-items: stretch; }
.quick-input-bar input { flex: 1; padding: .8rem 1rem; background: var(--bg-input); border: 2px solid var(--border-color); border-radius: var(--radius-lg); color: var(--text-primary); font-size: 1rem; font-family: inherit; }
.quick-input-bar input:focus { outline: none; border-color: var(--accent); }
.quick-input-bar input::placeholder { color: var(--text-muted); }

/* RESPONSIVE - Components */
@media (max-width: 1024px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.25rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card .card-value { font-size: 1.5rem; }
    .kanban-column { min-width: 260px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .search-input { min-width: unset; width: 100%; }
    .modal-container { max-width: 100%; margin: .5rem; }
    .quick-input-bar { flex-direction: column; }
    .quick-input-bar .btn { justify-content: center; }
    .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
    .toast { max-width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1; justify-content: center; }
}

/* UTILITY CLASSES */
.hidden { display: none !important; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
