/* Midnight Aurora Theme */

:root {
    --bg-dark: #0f0f13;
    --card-bg: rgba(22, 22, 28, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --accent-amber: #f5a623;
    --accent-violet: #a855f7;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --input-bg: rgba(0, 0, 0, 0.4);
    --input-border: rgba(255, 255, 255, 0.15);
    --border-radius: 16px;
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* Background Orbs */
.bg-orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-dark);
}

.bg-orbs::before,
.bg-orbs::after {
    content: "";
    position: absolute;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 20s infinite alternate;
}

.bg-orbs::before {
    background: radial-gradient(circle, var(--accent-amber), transparent 70%);
    top: -10%;
    left: -10%;
}

.bg-orbs::after {
    background: radial-gradient(circle, var(--accent-violet), transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 15%) scale(1.1); }
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
}

.inner-glass {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 24px;
}

/* Typography */
h1, h2, h3 {
    margin-top: 0;
    font-weight: 600;
}

#title {
    font-size: 32px;
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 0;
    margin-bottom: 24px;
    line-height: 1.5;
}

.app-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

/* Login Page */
.login-page, .contacts-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.contacts-page {
    align-items: flex-start;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 32px;
    text-align: center;
    animation: slideUp 0.6s ease-out;
}

/* Inputs */
.input-group {
    margin-bottom: 16px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-family);
    outline: none;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.1);
    background: rgba(0, 0, 0, 0.6);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Buttons */
.buttons {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    margin-bottom: 12px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-amber), var(--accent-violet));
    color: #fff;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages */
#loginResult, #registerResult, #contactAddResult, #contactSearchResult {
    display: block;
    margin-top: 12px;
    font-size: 14px;
    color: #ff6b6b; /* Default to error */
}

#registerResult, #contactAddResult {
    color: #4ade80; /* Success green */
}

/* Dashboard */
.dashboard-shell {
    width: 100%;
    max-width: 1000px;
    padding: 32px;
    animation: fadeIn 0.6s ease-out;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 16px;
}

.logout-glow {
    padding: 10px 20px;
    width: auto;
    margin: 0;
}

.form-row {
    margin-bottom: 24px;
}

.form-row input {
    width: 100%;
}

/* Contact Cards Grid */
.contact-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.contact-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    animation: fadeInStagger 0.5s backwards;
}

.contact-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.contact-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-amber), var(--accent-violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    margin-right: 16px;
    color: #fff;
    flex-shrink: 0;
}

.contact-info {
    flex-grow: 1;
    overflow: hidden;
}

.contact-card h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-details p {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.contact-details p:last-child {
    margin-bottom: 0;
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

.card-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-family);
}

.edit-button {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.edit-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.delete-button {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.delete-button:hover {
    background: rgba(239, 68, 68, 0.2);
}

.empty-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Add Contact Panel */
.add-toggle {
    max-width: 200px;
    margin-top: 24px;
}

.add-contact-panel {
    margin-top: 24px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.hidden-panel {
    display: none;
    opacity: 0;
}

.add-contact-panel:not(.hidden-panel) {
    animation: slideDown 0.4s ease-out forwards;
}

/* Edit Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden-panel) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden-panel) .modal-content {
    transform: translateY(0);
}

.edit-form {
    grid-template-columns: 1fr; /* Stack inputs vertically in modal */
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    margin-bottom: 0;
}

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

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

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

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

.success-pulse {
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(74, 222, 128, 0.4); }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
    }
    
    .contact-form {
        grid-template-columns: 1fr;
    }
    
    .dashboard-shell {
        padding: 24px;
    }
    
    .inner-glass {
        padding: 16px;
    }
}
