/* CSS Variables */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --background: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
}

/* App Container */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0 30px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 500;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 5px;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* List Items */
.list-container {
    max-height: 400px;
    overflow-y: auto;
}

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

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

.list-item-info {
    flex: 1;
}

.list-item-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.list-item-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

.days-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.days-badge.urgent {
    background: var(--warning-color);
}

.days-badge.today {
    background: var(--success-color);
}

.days-badge.overdue {
    background: var(--danger-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

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

.btn-secondary:hover {
    background: #d1d5db;
}

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--border-color);
}

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

/* Contacts View */
.contacts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-filter input,
.search-filter select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.search-filter input {
    min-width: 200px;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.contact-main {
    flex: 1;
}

.contact-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.contact-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.contact-details span {
    display: inline-block;
    margin-right: 15px;
}

.contact-context {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.relationship-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.relationship-badge.family { background: #dbeafe; color: #1e40af; }
.relationship-badge.friend { background: #dcfce7; color: #166534; }
.relationship-badge.colleague { background: #fef3c7; color: #92400e; }
.relationship-badge.partner { background: #fce7f3; color: #9d174d; }
.relationship-badge.other { background: #e5e7eb; color: #374151; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

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

/* Forms */
form {
    padding: 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Templates */
.section-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.templates-grid {
    display: grid;
    gap: 15px;
}

.template-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.template-type {
    font-weight: 600;
    text-transform: capitalize;
}

.template-text {
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.6;
}

.template-text[contenteditable="true"] {
    border: 1px solid var(--border-color);
    min-height: 80px;
}

.template-text[contenteditable="true"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Settings */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.success-text {
    color: var(--success-color);
    margin-bottom: 15px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

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

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

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    .contacts-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-filter {
        flex-direction: column;
    }

    .search-filter input {
        min-width: 100%;
    }

    .contact-card {
        flex-direction: column;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .list-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

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