/* ============================================
   Split Gastos - Mobile-first Styles
   ============================================ */

/* CSS Variables */
:root {
    --color-primary: #10B981;
    --color-primary-dark: #059669;
    --color-primary-light: #D1FAE5;
    --color-secondary: #6366F1;
    --color-danger: #EF4444;
    --color-danger-light: #FEE2E2;
    --color-warning: #F59E0B;
    --color-bg: #F3F4F6;
    --color-card: #FFFFFF;
    --color-text: #1F2937;
    --color-text-secondary: #6B7280;
    --color-text-muted: #9CA3AF;
    --color-border: #E5E7EB;
    --color-positive: #10B981;
    --color-negative: #EF4444;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: 0.2s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
}

.header-spacer {
    width: 44px;
}

/* Main Content */
.main {
    flex: 1;
    padding: 16px;
    padding-bottom: 100px;
    overflow-y: auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #D1D5DB;
}

.btn-danger-text {
    background: transparent;
    color: var(--color-danger);
    padding: 12px;
}

.btn-danger-text:hover {
    background: var(--color-danger-light);
}

.btn-full {
    width: 100%;
}

.btn-fab {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background var(--transition);
    touch-action: manipulation;
}

.btn-icon:hover {
    background: var(--color-bg);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.btn-small:hover {
    background: #A7F3D0;
}

/* Forms */
.form-section {
    margin-bottom: 20px;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card);
    transition: border-color var(--transition);
}

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

.input::placeholder {
    color: var(--color-text-muted);
}

.input-amount {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 8px;
}

/* Members Input */
.members-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.members-input-row .input {
    flex: 1;
}

.members-input-row .btn {
    white-space: nowrap;
}

/* Member Chips */
.members-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.member-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background var(--transition);
}

.member-chip-remove:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Groups List */
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-card {
    display: block;
    padding: 16px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.group-card:hover {
    box-shadow: var(--shadow-md);
}

.group-card:active {
    transform: scale(0.99);
}

.group-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.group-card-info {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--color-text-secondary);
}

.empty-inline {
    padding: 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Sections */
.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Expenses List */
.expenses-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.expense-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.expense-info {
    flex: 1;
    min-width: 0;
}

.expense-desc {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-detail {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.expense-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-left: 12px;
    white-space: nowrap;
}

.expense-delete {
    width: 32px;
    height: 32px;
    margin-left: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.expense-delete:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* Settlement List */
.settlement-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settlement-card {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.settlement-arrow {
    margin: 0 12px;
    color: var(--color-text-muted);
}

.settlement-from {
    font-weight: 600;
    color: var(--color-negative);
}

.settlement-to {
    font-weight: 600;
    color: var(--color-positive);
}

.settlement-amount {
    margin-left: auto;
    font-weight: 700;
    font-size: 1.125rem;
}

/* Add Form (inline) */
.add-form {
    padding: 16px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
}

.add-form .input {
    margin-bottom: 12px;
}

.add-form-actions {
    display: flex;
    gap: 8px;
}

.add-form-actions .btn {
    flex: 1;
}

/* Footer Actions */
.footer-actions {
    padding: 16px;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
}

.footer-danger {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 8px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--color-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-height: auto;
    border-radius: var(--radius-lg);
    margin: auto 16px;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

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

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

.modal-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--color-border);
}

.modal-footer-row {
    display: flex;
    gap: 12px;
}

.modal-footer-row .btn {
    flex: 1;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-option {
    display: none;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--color-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.radio-option:checked + .radio-label {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-option {
    display: none;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--color-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.checkbox-option:checked + .checkbox-label {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

.split-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 100px;
    left: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    background: var(--color-text);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    text-align: center;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
    pointer-events: auto;
}

.toast.success {
    background: var(--color-primary);
}

.toast.error {
    background: var(--color-danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Desktop Enhancements */
@media (min-width: 768px) {
    .main {
        max-width: 600px;
        margin: 0 auto;
        padding: 24px;
    }

    .btn-fab {
        position: fixed;
        bottom: 32px;
        left: 50%;
        transform: translateX(-50%);
    }

    .modal-content {
        border-radius: var(--radius-lg);
        margin: auto;
        max-height: 80vh;
    }

    .modal {
        align-items: center;
        padding: 24px;
    }

    .group-card:hover {
        transform: translateY(-2px);
    }

    .footer-danger {
        bottom: 100px;
    }
}
