:root {
    /* Color Palette - Modern Flat Colors */
    --primary-color: #2c3e50;    /* Dark Blue/Grey */
    --secondary-color: #34495e;  /* Lighter Blue/Grey */
    --accent-color: #3498db;     /* Bright Blue */
    --accent-hover: #2980b9;
    --text-color: #000000;
    --text-light: #7f8c8d;
    --bg-color: #f8f9fa;
    --sidebar-width: 300px;
    --header-height: 60px;
    
    /* Gender Colors - Softer tones */
    --male-color: #e74c3c;
    --female-color: #2ecc71;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul {
    list-style: none;
}

/* Layout */
.main-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar-wrapper {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: #ecf0f1;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.content-wrapper {
    flex-grow: 1;
    padding: 30px;
    background-color: var(--bg-color);
    width: 100%; /* Ensure full width */
}

/* Sidebar Styling */
.sidebar-header {
    padding: 30px 20px;
    background-color: var(--secondary-color);
    text-align: center;
    position: relative;
}

.logo-area {
    margin-bottom: 15px;
    color: var(--accent-color);
}

.logo-area .main-logo {
    width: 170px;
    height: 130px;
    border-radius: 5%;
    object-fit: cover;
    border: none solid var(--accent-color);
    box-shadow: var(--shadow-lg);
}

.sidebar-header .family-title {
    font-size: 1.5em;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
    line-height: 1.2;
}

.sidebar-header h3 {
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 1.4em;
    letter-spacing: 0.5px;
}

.sidebar-header p {
    font-size: 0.85em;
    color: #bdc3c7;
    line-height: 1.4;
}

.sidebar-search {
    padding: 20px 15px;
    background-color: rgba(0,0,0,0.1);
}

.sidebar-search .search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.sidebar-search input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: none;
    padding: 10px 12px;
    color: #fff;
    outline: none;
    border-radius: 4px;
}

.sidebar-search input::placeholder {
    color: rgba(255,255,255,0.5);
}

.sidebar-search .search-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: rgba(255,255,255,0.9);
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.sidebar-search .search-btn:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

.sidebar-search .search-btn i {
    font-size: 14px;
}

.sidebar-search select {
    width: 100%;
    padding: 8px;
    background-color: rgba(255,255,255,0.1);
    color: #ecf0f1;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
}

.sidebar-search select option {
    background-color: var(--primary-color);
}

/* Sidebar Menu */
.sidebar-menu ul li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #bdc3c7;
    border-left: 3px solid transparent;
    font-size: 0.95em;
}

.sidebar-menu ul li a:hover, .sidebar-menu ul li a.active {
    background-color: rgba(255,255,255,0.05);
    color: white;
    border-left-color: var(--accent-color);
}

.sidebar-menu ul li i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Submenu */
.submenu {
    background-color: rgba(0,0,0,0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submenu.active {
    max-height: 500px;
}

.submenu li a {
    padding-left: 55px;
    font-size: 0.9em;
}

/* Mobile Header */
.mobile-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.mobile-header h3 {
    margin-left: 15px;
    font-size: 1.2em;
    font-weight: 500;
}

.menu-toggle, .close-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
}

.close-sidebar {
    position: absolute;
    top: 15px;
    right: 15px;
}

/* Utility Classes */
.d-md-none { display: none; }

/* Content Styling */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-weight: 600;
}

h1 { font-size: 2em; }
h2 { font-size: 1.5em; color: var(--text-light); font-weight: 400; }

.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 25px;
    margin-bottom: 25px;
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95em;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85em;
}

.btn-warning { background-color: #f39c12; }
.btn-danger { background-color: #e74c3c; }

/* Forms */
.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: #f8f9fa;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 1px;
    padding: 15px;
    border-bottom: 2px solid #eee;
}

.table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background-color: #fcfcfc;
}

/* Mobile Header - Hidden by default */
.mobile-header {
    display: none;
}

/* Close sidebar button - Hidden on desktop */
.close-sidebar {
    display: none;
}

/* Responsive Media Queries - Tablet */
@media (max-width: 768px) {
    .d-md-none { display: block; }
    
    /* Mobile Header */
    .mobile-header {
        display: flex;
        align-items: center;
        padding: 12px 15px;
        background: var(--primary-color);
        color: #fff;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 998;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    .mobile-header h3 {
        margin: 0 0 0 15px;
        font-size: 1.1em;
        color: #fff;
    }
    
    .menu-toggle {
        background: rgba(255,255,255,0.1);
        border: none;
        color: #fff;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2em;
    }
    
    .main-layout {
        flex-direction: column;
    }
    
    /* Add padding to content for mobile header */
    .content-wrapper {
        padding-top: 70px;
    }
    
    /* Close button for mobile sidebar */
    .close-sidebar {
        display: block;
        position: absolute;
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        background: rgba(255,255,255,0.1);
        border: none;
        border-radius: 50%;
        color: #fff;
        font-size: 1em;
        cursor: pointer;
        z-index: 10;
    }
    
    .close-sidebar:hover {
        background: rgba(255,255,255,0.2);
    }
    
    .sidebar-wrapper {
        position: fixed;
        top: 0;
        left: -100%;
        width: 260px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar-wrapper.active {
        left: 0;
    }
    
    /* Adjust sidebar content for smaller width */
    .sidebar-wrapper .sidebar {
        width: 260px !important;
        min-width: 260px !important;
    }
    
    .sidebar-wrapper .sidebar-header {
        padding: 20px 15px;
    }
    
    .sidebar-wrapper .main-logo {
        width: 120px;
        height: 90px;
    }
    
    .sidebar-wrapper .family-title {
        font-size: 1.1em;
    }
    
    .sidebar-wrapper .sidebar-search {
        padding: 15px 12px;
    }
    
    .sidebar-wrapper .sidebar-menu a {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .sidebar-wrapper .sidebar-menu a i {
        margin-right: 12px;
        width: 18px;
    }
    
    /* Mobile sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .content-wrapper {
        padding: 15px;
    }
    
    h1 { font-size: 1.5em; }
    h2 { font-size: 1.3em; }
    h3 { font-size: 1.1em; }
    
    /* Form responsive */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group.half {
        width: 100%;
    }
    
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }
    
    /* Button responsive */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px; /* Touch target */
    }
    
    /* Table responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 14px;
    }
    
    /* Card responsive */
    .card {
        padding: 15px;
    }
    
    /* Grid responsive */
    .grid {
        grid-template-columns: 1fr;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    /* Trah grid */
    .trah-grid {
        grid-template-columns: 1fr;
    }
    
    /* Tree canvas */
    .tree-canvas-container {
        height: 60vh;
    }
    
    /* Member detail */
    .member-header {
        flex-direction: column;
        text-align: center;
    }
    
    .member-photo {
        width: 120px;
        height: 120px;
        margin: 0 auto 15px;
    }
    
    /* Login form */
    .login-container {
        margin: 20px;
        padding: 30px 20px;
    }
}

/* Responsive - Mobile Small */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .content-wrapper {
        padding: 10px;
    }
    
    h1 { font-size: 1.3em; }
    h2 { font-size: 1.15em; }
    
    /* Stats grid single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Form */
    .form-section {
        padding: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Buttons full width on mobile */
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 5px 0;
    }
    
    /* Table */
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 8px 5px;
    }
    
    /* Sidebar */
    .sidebar-wrapper {
        width: 260px;
    }
    
    /* Gallery */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* Spouse section */
    .spouse-entry {
        padding: 15px;
    }
    
    /* Dashboard cards */
    .dashboard-card {
        padding: 15px;
    }
    
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .trah-card,
    .sidebar-menu a {
        min-height: 44px;
        min-width: 44px;
    }
    
    select,
    input,
    textarea {
        font-size: 16px !important; /* Prevent zoom on focus */
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-home, .page-tree, .page-members, .page-detail, .page-users {
    animation: fadeIn 0.5s ease-out;
}

/* Sidebar Divider */
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 10px 20px;
}
