:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --danger: #EF4444;
    --sidebar-bg: #0F172A;
    --sidebar-text: #F9FAFB;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* Layout Structure */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar - Desktop Default */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
}

.logo-box {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.75rem;
    cursor: pointer;
    padding: 4px;
}

.sidebar-nav {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94A3B8;
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background-color: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 500;
    flex-shrink: 0;
}

.topbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* Mobile Components */
.mobile-toggle-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.mobile-toggle-btn span {
    width: 100%;
    height: 2px;
    background-color: #1F2937;
    border-radius: 2px;
    transition: var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ========================================= */
/* MOBILE & TABLET STYLES (THE CORE REMAKE)  */
/* ========================================= */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 2000;
        width: 280px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.3);
    }

    .sidebar-close-btn {
        display: block;
    }

    .mobile-toggle-btn {
        display: flex;
    }

    /* Morph Hamburger to X */
    body.sidebar-open .mobile-toggle-btn span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    body.sidebar-open .mobile-toggle-btn span:nth-child(2) {
        opacity: 0;
    }

    body.sidebar-open .mobile-toggle-btn span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .topbar {
        height: 60px;
        padding: 0 16px;
    }

    .content-area {
        padding: 20px 16px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 16px;
        margin-bottom: 20px;
    }

    .view-header .btn {
        width: 100%;
        justify-content: center;
    }

    .projects-grid,
    .tools-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .card {
        padding: 20px !important;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .container {
        padding: 0;
    }
}

/* Extra Small Phones */
@media (max-width: 480px) {
    #page-title {
        font-size: 1.1rem;
    }

    .sidebar {
        width: 85%;
    }
}

/* Common UI Elements */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-planned {
    background: #EEF2FF;
    color: #4F46E5;
}

.status-in_progress {
    background: #FFF7ED;
    color: #EA580C;
}

.status-completed {
    background: #F0FDF4;
    color: #16A34A;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* Project Details Specifics */
#project-details-view .projects-grid {
    grid-template-columns: 1fr 2fr;
}

@media (max-width: 768px) {
    #project-details-view .projects-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Image delete button */
.img-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    z-index: 10;
    line-height: 1;
}

.img-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}