:root {
    --bg-color: #0a0b10;
    --surface-color: rgba(255, 255, 255, 0.03);
    --surface-border: rgba(255, 255, 255, 0.08);
    --primary-color: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent-color: #8b5cf6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-blur: blur(12px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-theme {
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --surface-border: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --primary-glow: rgba(59, 130, 246, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

input, select, textarea {
    color: var(--text-primary) !important;
}

option {
    background: var(--bg-color);
    color: var(--text-primary);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 40%);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--surface-color);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    transition: var(--transition);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
}

.nav-item {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background: var(--surface-border);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.search-bar {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    width: 400px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
}

/* Contacts Grid */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.contact-card {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    padding: 1.5rem;
    border-radius: 20px;
    backdrop-filter: var(--glass-blur);
    transition: var(--transition);
    position: relative;
    overflow: visible; /* FIXED: Permite que o menu de contexto (3 pontinhos) vaze para fora do card e fique visível */
}

.contact-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px -10px var(--primary-glow);
    z-index: 2; /* Garante que o card fique por cima dos outros quando em hover */
}

/* List View Overrides */
.contacts-grid.list-view {
    grid-template-columns: 1fr;
    gap: 0.8rem;
}
.contacts-grid.list-view .contact-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 1.5rem;
    gap: 1.5rem;
}
.contacts-grid.list-view .contact-card:hover {
    transform: translateX(5px);
}
/* Fix absolute checkbox in list view */
.contacts-grid.list-view .contact-card > div[style*="position: absolute"] {
    position: static !important;
    margin: 0;
    padding: 0;
}
.contacts-grid.list-view .contact-header {
    margin-bottom: 0;
    width: auto;
    min-width: 280px;
    padding-left: 0 !important;
}
.contacts-grid.list-view .contact-header h3 {
    max-width: 200px !important;
}
.contacts-grid.list-view .contact-details-container {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center;
    flex-wrap: wrap;
}
.contacts-grid.list-view .contact-details-container > div {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}
.contacts-grid.list-view .contact-actions {
    margin-top: 0 !important;
    display: flex !important;
    padding-left: 0 !important;
    gap: 0.5rem !important;
}
.contacts-grid.list-view .btn {
    padding: 0.5rem 0.8rem !important;
}

.contact-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 20px 20px 0 0; /* FIXED: Mantém as bordas arredondadas já que removemos o overflow hidden */
    opacity: 0;
    transition: var(--transition);
}

.contact-card:hover::before {
    opacity: 1;
}

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

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    background: var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.contact-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.contact-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.contact-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
}

.btn:hover {
    filter: brightness(1.2);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.contact-card {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 1.5rem 0.5rem;
        align-items: center;
    }
    .logo span, .nav-item span {
        display: none;
    }
    .nav-item {
        justify-content: center;
        width: 50px;
        height: 50px;
        padding: 0;
    }
    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 0.8rem;
        border-right: none;
        border-bottom: 1px solid var(--surface-border);
        position: sticky;
        top: 0;
        z-index: 50;
    }
    .logo {
        margin-bottom: 0;
        margin-right: 1rem;
    }
    .nav-links {
        display: flex;
        gap: 0.5rem;
    }
    .nav-item {
        margin-bottom: 0;
    }
    .search-bar {
        width: 100%;
    }
    .header {
        flex-direction: column;
        gap: 1.5rem;
        align-items: stretch;
    }
    .user-profile {
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .contacts-grid {
        grid-template-columns: 1fr;
    }
    #modal > div {
        width: 95%;
        padding: 1.5rem;
    }
}

/* -----------------------------
   UX / UI Premium Additions
   ----------------------------- */

/* Glassmorphism Background Orbs */
.background-orbs {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: floatOrb 20s infinite ease-in-out alternate;
}
.orb-1 { width: 500px; height: 500px; background: var(--primary-color); top: -10%; left: -10%; }
.orb-2 { width: 400px; height: 400px; background: var(--accent-color); bottom: -10%; right: -5%; animation-delay: -5s; }
@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

/* Sidebar Blur */
.sidebar {
    background: rgba(10, 11, 16, 0.6) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}
.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.7) !important;
}

/* Toast Notifications */
#toastContainer {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--surface-border);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #f8fafc;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.light-theme .toast {
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
}
.toast.success i { color: #10b981; }
.toast.error i { color: #ef4444; }
.toast.fade-out {
    animation: fadeOutRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* Context Menu (3-dots) */
.context-menu-wrapper {
    position: relative;
}
.context-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}
.context-btn:hover {
    background: var(--surface-border);
    color: var(--text-primary);
}
.context-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background: #1e293b;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 150px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 100;
    display: none;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}
.light-theme .context-menu { background: #ffffff; }
.context-menu.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}
.context-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
}
.context-item:hover {
    background: rgba(255,255,255,0.05);
}
.light-theme .context-item:hover {
    background: rgba(0,0,0,0.05);
}
.context-item.danger { color: #ef4444; }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
}
.light-theme .skeleton {
    background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.05) 75%);
    background-size: 400% 100%;
}
@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.skeleton-card {
    height: 180px;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    grid-column: 1 / -1;
}
.empty-state i {
    color: var(--text-secondary);
    opacity: 0.5;
    margin-bottom: 1.5rem;
    animation: floatOrb 6s infinite ease-in-out alternate;
}
.empty-state h3 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.empty-state p { color: var(--text-secondary); margin-bottom: 2rem; max-width: 300px; }
