/* ===== Variáveis ===== */
:root {
    --primary: #e74c8b;
    --primary-dark: #c0396e;
    --primary-light: #f5a0c0;
    --secondary: #9b59b6;
    --secondary-dark: #7d3c98;
    --bg: #fdf2f8;
    --bg-card: #ffffff;
    --text: #2d1f3d;
    --text-secondary: #6b5b7b;
    --border: #f0d4e8;
    --success: #27ae60;
    --danger: #e74c3c;
    --shadow: 0 2px 12px rgba(155, 89, 182, 0.12);
    --shadow-lg: 0 8px 30px rgba(155, 89, 182, 0.18);
    --radius: 16px;
    --radius-sm: 10px;
    --max-width: 500px;
    --header-height: 60px;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a0e1f;
        --bg-card: #2d1f3d;
        --text: #f5e6ff;
        --text-secondary: #c4a8d8;
        --border: #3d2a50;
        --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    }
}

/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ===== Splash ===== */
.splash {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 999;
    transition: opacity 0.3s;
}

.splash.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* ===== Screens ===== */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== Auth Screen ===== */
.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo svg {
    filter: drop-shadow(0 4px 12px rgba(231, 76, 139, 0.3));
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.auth-logo h1 {
    font-size: 32px;
    color: var(--primary);
    margin-top: 12px;
    font-weight: 700;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 14px;
}

.auth-form {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text);
    font-size: 20px;
}

.auth-forgot {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
}

.auth-forgot a {
    color: var(--text-secondary);
}

.forgot-desc {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.4;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    font-weight: 600;
}

.error-msg {
    background: #fde8e8;
    color: var(--danger);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    font-size: 14px;
    text-align: center;
    width: 100%;
}

@media (prefers-color-scheme: dark) {
    .error-msg {
        background: rgba(231, 76, 60, 0.15);
    }
}

/* ===== Inputs ===== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input[type="text"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group input[type="url"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.2s;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
}

.input-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ===== Buttons ===== */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:active {
    background: var(--border);
}

.btn-danger {
    padding: 12px 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:active {
    background: rgba(0,0,0,0.05);
}

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    max-width: 100%;
}

.app-header h1 {
    font-size: 22px;
    color: var(--primary);
    font-weight: 700;
}

.header-menu-wrap {
    position: relative;
}

.header-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 20;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.dropdown-item:active {
    background: var(--border);
}

.dropdown-danger {
    color: var(--danger);
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

.filter-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: transparent;
}

/* ===== Gifts Grid ===== */
.gifts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 20px 100px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

/* ===== Gift Card ===== */
.gift-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gift-card:active {
    transform: scale(0.97);
}

.gift-card.comprado {
    opacity: 0.65;
}

.gift-card.comprado .gift-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(39, 174, 96, 0.2);
}

.gift-card.comprado .gift-check {
    color: var(--success);
}

.gift-img {
    width: 100%;
    aspect-ratio: 1;
    background: var(--border);
    position: relative;
    overflow: hidden;
}

.gift-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gift-img .no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--primary-light);
}

.gift-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
}

.gift-info {
    padding: 10px 12px;
}

.gift-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gift-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 2px;
}

.gift-actions {
    display: flex;
    gap: 4px;
    padding: 0 8px 8px;
    justify-content: space-between;
    align-items: center;
}

.gift-actions button {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gift-actions button:active {
    background: var(--border);
}

.btn-comprar {
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px !important;
    border-radius: 14px !important;
    border: 1.5px solid var(--border) !important;
    background: var(--bg) !important;
    color: var(--text-secondary) !important;
}

.btn-comprar.marcado {
    border-color: var(--success) !important;
    background: rgba(39, 174, 96, 0.1) !important;
    color: var(--success) !important;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state p {
    margin-top: 16px;
    font-size: 18px;
    font-weight: 600;
}

.empty-hint {
    font-size: 14px !important;
    font-weight: 400 !important;
    opacity: 0.7;
    margin-top: 4px !important;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== FAB ===== */
.fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(231, 76, 139, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 5;
}

.fab:active {
    transform: scale(0.9);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    animation: fadeInBg 0.2s ease;
}

@keyframes fadeInBg {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    width: 100%;
    max-width: var(--max-width);
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-small {
    border-radius: var(--radius);
    margin: 20px;
    max-width: 340px;
    animation: fadeIn 0.2s ease;
}

.modal-small h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.modal-small p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal.hidden {
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* ===== Photo Upload ===== */
.photo-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.photo-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-tab.active {
    background: var(--primary);
    color: white;
}

.photo-tab-content {
    display: none;
}

.photo-tab-content.active {
    display: block;
}

.file-upload {
    display: block;
    cursor: pointer;
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.file-upload-label:active {
    border-color: var(--primary);
}

.photo-preview {
    margin-top: 12px;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.photo-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.btn-remove-photo {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    animation: toastIn 0.3s ease;
    white-space: nowrap;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.hidden {
    display: none;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Responsivo ===== */
@media (min-width: 500px) {
    .modal-content:not(.modal-small) {
        border-radius: var(--radius);
        margin-bottom: 5vh;
    }

    .modal {
        align-items: center;
    }
}

/* Safe area para iPhone */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .fab {
        bottom: calc(28px + env(safe-area-inset-bottom));
    }

    .gifts-grid {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}
