/**
 * CRM Mobile-First - Stile Casaè
 */

/* === RESET & BASE === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --primary-light: #fadbd8;
    --secondary: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --dark: #2c3e50;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --white: #ffffff;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === LOGIN PAGE === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 380px;
}

.login-box {
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--dark);
    font-size: 1.75rem;
    font-weight: 700;
}

.login-box .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* === FORMS === */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--white);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

input::placeholder {
    color: var(--gray-400);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

/* === ALERTS === */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* === APP LAYOUT === */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 70px;
}

/* Header */
.app-header {
    background: var(--white);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
}

.header-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.875rem;
}

/* Main content */
.app-main {
    flex: 1;
    padding: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

/* Bottom Navigation */
.app-nav {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-inner {
    display: flex;
    justify-content: space-around;
    max-width: 500px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.625rem 0.75rem;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.25rem;
}

/* === CARDS === */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

/* === STATS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.stat-card.stat-blue::before {
    background: var(--secondary);
}

.stat-card.stat-green::before {
    background: var(--success);
}

.stat-card.stat-orange::before {
    background: var(--warning);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
}

.stat-card.stat-blue .stat-icon {
    background: #dbeafe;
    color: var(--secondary);
}

.stat-card.stat-green .stat-icon {
    background: #d1fae5;
    color: var(--success);
}

.stat-card.stat-orange .stat-icon {
    background: #fef3c7;
    color: var(--warning);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* === LISTS === */
.list {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-header {
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    gap: 1rem;
}

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

.list-item:hover,
.list-item:active {
    background: var(--gray-50);
}

.list-item-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    flex-shrink: 0;
}

.list-item-icon.icon-red {
    background: var(--primary-light);
    color: var(--primary);
}

.list-item-icon.icon-blue {
    background: #dbeafe;
    color: var(--secondary);
}

.list-item-icon.icon-green {
    background: #d1fae5;
    color: var(--success);
}

.list-item-icon.icon-orange {
    background: #fef3c7;
    color: var(--warning);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dark);
}

.list-item-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-meta {
    text-align: right;
    flex-shrink: 0;
}

.list-item-time {
    font-size: 0.8rem;
    color: var(--gray-400);
}

.list-item-arrow {
    color: var(--gray-300);
}

/* === BADGE === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-blue {
    background: #dbeafe;
    color: var(--secondary);
}

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

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

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

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* === AGENDA === */
.agenda-section {
    margin-bottom: 2rem;
}

.agenda-date-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.agenda-date-badge {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.agenda-date-badge .day {
    font-size: 1.25rem;
    line-height: 1;
}

.agenda-date-badge .month {
    font-size: 0.65rem;
    text-transform: uppercase;
}

.agenda-date-text {
    font-weight: 600;
    color: var(--dark);
}

.agenda-date-text span {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 400;
}

.agenda-event {
    display: flex;
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.agenda-event:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.agenda-event-color {
    width: 4px;
    background: var(--primary);
    flex-shrink: 0;
}

.agenda-event-color.color-blue {
    background: var(--secondary);
}

.agenda-event-color.color-green {
    background: var(--success);
}

.agenda-event-color.color-orange {
    background: var(--warning);
}

.agenda-event-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agenda-event-time {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 50px;
}

.agenda-event-info {
    flex: 1;
}

.agenda-event-title {
    font-weight: 600;
    color: var(--dark);
}

.agenda-event-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* === SEARCH & FILTERS === */
.search-container {
    margin-bottom: 1rem;
}

.search-box {
    position: relative;
}

.search-box input {
    padding-left: 3rem;
    padding-right: 1rem;
    background: var(--white);
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    width: 20px;
    height: 20px;
}

.filters-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.filters-container::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip:hover {
    border-color: var(--gray-300);
}

.filter-chip.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* === FLOATING ACTION BUTTON === */
.fab {
    position: fixed;
    bottom: calc(70px + 1rem + env(safe-area-inset-bottom));
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 90;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-400);
    font-size: 0.9rem;
}

/* === LOADING === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--white);
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-400);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 0.75rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* === DETAIL PAGE === */
.detail-header {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.detail-subtitle {
    color: var(--gray-500);
}

.detail-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.detail-section-title {
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.detail-row {
    display: flex;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    width: 40%;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.detail-value {
    flex: 1;
    font-weight: 500;
    color: var(--dark);
}

/* === TABS === */
.tabs {
    display: flex;
    background: var(--white);
    border-radius: var(--radius);
    padding: 0.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    font-weight: 500;
    color: var(--gray-500);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: var(--white);
}

/* === UTILITIES === */
.text-center {
    text-align: center;
}

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

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

.text-muted {
    color: var(--gray-500);
}

.font-bold {
    font-weight: 700;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.p-1 {
    padding: 0.5rem;
}

.p-2 {
    padding: 1rem;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

/* === RESPONSIVE === */
@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .app-main {
        padding: 2rem;
    }

    .modal {
        border-radius: var(--radius-lg);
        margin: 2rem;
        max-height: calc(100vh - 4rem);
    }

    .modal-overlay {
        align-items: center;
    }

    .fab {
        bottom: 2rem;
        right: 2rem;
    }

    .app-container {
        padding-bottom: 0;
    }

    .app-nav {
        position: static;
        width: 80px;
        border-top: none;
        border-right: 1px solid var(--gray-200);
    }

    .nav-inner {
        flex-direction: column;
        padding: 1rem 0;
    }

    .app-container {
        flex-direction: row;
    }
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fade {
    animation: fadeIn 0.3s ease;
}

.animate-slide {
    animation: slideUp 0.3s ease;
}