/* General Body and HTML Reset */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    display: flex;
    min-height: 100vh; /* Full viewport height */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Base Link Styles */
a {
    color: #00796b; /* Teal */
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #004d40; /* Darker Teal */
    text-decoration: underline;
}

/* Wrapper for Sidebar and Main Content */
.wrapper {
    display: flex;
    width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 250px;
    background-color: #00796b; /* Teal */
    color: #fff;
    padding: 20px 0;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    position: fixed; /* Keep sidebar fixed */
    height: 100%; /* Full height */
    overflow-y: auto; /* Scrollable if content is long */
}

.sidebar-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 300;
    letter-spacing: 1px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    position: relative; /* For sub-menu positioning */
}

.sidebar ul li a {
    display: block;
    color: #fff;
    padding: 12px 20px;
    font-size: 1.05em;
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease, padding-left 0.3s ease;
    white-space: nowrap; /* Prevent wrapping */
}

.sidebar ul li a i {
    margin-right: 10px;
    font-size: 1.1em;
}

.sidebar ul li a:hover,
.sidebar ul li a.active {
    background-color: #004d40; /* Darker Teal */
    padding-left: 25px; /* Slight indent on hover/active */
}

/* Sub-menu for nested items (e.g., Clients, Invoices) */
.sidebar ul li ul {
    background-color: #004d40; /* Slightly darker than parent for distinction */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar ul li:hover > ul,
.sidebar ul li.active > ul { /* active class can be added by JS/PHP if current page is in submenu */
    max-height: 200px; /* Adjust based on max content height */
    transition: max-height 0.5s ease-in;
}


.sidebar ul li ul li a {
    padding: 8px 20px 8px 40px; /* Indent sub-menu items */
    font-size: 0.95em;
    background-color: #004d40; /* Inherit parent darker background */
}

.sidebar ul li ul li a:hover,
.sidebar ul li ul li a.active {
    background-color: #00382d; /* Even darker for sub-menu hover */
    padding-left: 45px;
}


/* Main Content Area */
.main-content {
    margin-left: 250px; /* Offset for the fixed sidebar */
    flex-grow: 1; /* Take remaining space */
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Header within Main Content */
.header {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 1.8em;
    color: #00796b;
}

.profile-info {
    display: flex;
    align-items: center;
    font-size: 1.1em;
    color: #555;
}

.profile-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 2px solid #eee;
}

.profile-info i { /* For default user icon */
    margin-right: 10px;
    color: #00796b;
}

/* Card Styling for Sections */
.card {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

/* Form Section Styling */
.form-section h2, .data-list-section h2, .data-summary-section h2 {
    color: #00796b;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.input-group input[type="text"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group input[type="date"],
.input-group textarea,
.input-group select {
    width: calc(100% - 22px); /* Account for padding and border */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box; /* Include padding and border in width */
    transition: border-color 0.3s ease;
}

.input-group input[type="file"] {
    padding: 8px 0;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: #00796b;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 121, 107, 0.2);
}

textarea {
    resize: vertical; /* Allow vertical resizing only */
    min-height: 80px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-action {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    text-align: center;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    border: none;
}

.btn-primary {
    background-color: #00796b;
    color: #fff;
    margin-right: 10px;
}

.btn-primary:hover {
    background-color: #005a4e;
}

.btn-secondary {
    background-color: #f0f0f0;
    color: #555;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
}

.btn-add-new {
    margin-bottom: 20px;
    display: inline-flex; /* For icon alignment */
    align-items: center;
    gap: 8px; /* Space between icon and text */
}

/* Action Buttons within tables/cards */
.btn-action {
    padding: 6px 10px;
    font-size: 0.9em;
    margin-right: 5px;
    border: 1px solid transparent;
    color: #fff;
}

.btn-action i {
    margin: 0; /* Remove margin for single icon buttons */
}

.btn-action.edit-btn { background-color: #2196f3; } /* Blue */
.btn-action.edit-btn:hover { background-color: #1976d2; }

.btn-action.delete-btn { background-color: #f44336; } /* Red */
.btn-action.delete-btn:hover { background-color: #d32f2f; }

.btn-action.view-btn { background-color: #607d8b; } /* Blue Grey */
.btn-action.view-btn:hover { background-color: #455a64; }

.btn-action.complete-btn { background-color: #4CAF50; } /* Green */
.btn-action.complete-btn:hover { background-color: #388E3C; }

.btn-action.pending-btn { background-color: #ff9800; } /* Orange */
.btn-action.pending-btn:hover { background-color: #f57c00; }


/* Table Styling */
.table-responsive {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden; /* Ensures border-radius applies to corners */
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #e0f2f1; /* Light Teal */
    color: #00796b;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tbody tr:hover {
    background-color: #f2f2f2;
}

/* Specific table column widths/alignments */
.data-table td:last-child,
.data-table th:last-child {
    text-align: center; /* Actions column */
    white-space: nowrap; /* Keep buttons on one line */
}

.data-table td.text-right {
    text-align: right;
}


/* Dashboard Specific Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.dashboard-card {
    padding: 25px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

.dashboard-card .icon {
    font-size: 3em;
    color: #00796b;
    margin-bottom: 15px;
}

.dashboard-card h3 {
    margin: 0 0 10px 0;
    color: #555;
    font-size: 1.3em;
}

.dashboard-card .value {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
}

.dashboard-card .link-btn {
    background-color: #00796b;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.95em;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.dashboard-card .link-btn:hover {
    background-color: #005a4e;
    text-decoration: none;
}

/* Message Styling (Success/Error/Info) */
.success-message, .error-message, .info-message {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: bold;
    border: 1px solid;
    display: flex;
    align-items: center;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.info-message {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* Invoice Specific Styles */
.invoice-details p {
    margin: 5px 0;
}

.invoice-details .header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.invoice-details .header-section div {
    flex: 1;
}

.invoice-details .header-section .logo {
    max-width: 150px;
    height: auto;
    display: block;
    margin-bottom: 10px;
}

.invoice-details .header-section h2 {
    margin-top: 0;
    color: #00796b;
    font-size: 1.8em;
}

.invoice-details .company-info,
.invoice-details .client-info,
.invoice-details .invoice-meta {
    padding: 10px 0;
}

.invoice-details .invoice-meta {
    text-align: right;
}

.invoice-details .invoice-meta strong {
    display: inline-block;
    width: 120px; /* Align labels */
}

.invoice-items-table {
    margin-top: 20px;
}

.invoice-items-table th, .invoice-items-table td {
    padding: 10px;
    border: 1px solid #ddd;
}

.invoice-summary {
    width: 40%;
    float: right;
    margin-top: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f9f9f9;
}

.invoice-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.invoice-summary .summary-row:last-child {
    border-bottom: none;
    font-weight: bold;
    background-color: #e0f2f1;
    color: #00796b;
    font-size: 1.1em;
}

.invoice-summary .summary-row.total-due {
    background-color: #00796b;
    color: #fff;
    font-size: 1.2em;
}

.invoice-summary .summary-row span:first-child {
    font-weight: bold;
}

.invoice-actions {
    clear: both;
    padding-top: 20px;
    text-align: right;
}

.invoice-actions .btn-primary {
    margin-left: 10px;
}

/* For Invoice Create/Edit Forms */
.invoice-item-entry {
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    background-color: #fdfdfd;
}

.invoice-item-entry .input-group {
    margin-bottom: 10px;
}

.invoice-item-entry .remove-item-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    float: right;
    margin-top: -10px; /* Pull it up slightly */
}

.invoice-item-entry .remove-item-btn:hover {
    background-color: #d32f2f;
}

.add-item-btn {
    background-color: #4CAF50;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
}

.add-item-btn:hover {
    background-color: #388E3C;
}

/* Tasks Page Specific */
.tasks-table tr.completed {
    text-decoration: line-through;
    color: #888;
    background-color: #e8f5e9; /* Light green background */
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
}

.status-pending { background-color: #ff9800; } /* Orange */
.status-in-process { background-color: #2196f3; } /* Blue */
.status-completed { background-color: #4CAF50; } /* Green */
.status-cancelled { background-color: #f44336; } /* Red */

/* Notes Page Specific */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.note-card {
    padding: 20px;
    background-color: #fff;
    border-left: 5px solid #00796b;
    position: relative;
    display: flex;
    flex-direction: column;
}

.note-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #00796b;
    font-size: 1.3em;
}

.note-card .note-content {
    flex-grow: 1; /* Allow content to take up space */
    margin-bottom: 15px;
    font-size: 0.95em;
    overflow-wrap: break-word; /* Ensure long words break */
    white-space: pre-wrap; /* Preserve whitespace and breaks */
}

.note-card .note-date {
    display: block;
    font-size: 0.8em;
    color: #888;
    margin-top: auto; /* Push date to bottom */
}

.note-card .note-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 5px;
}

.note-card .note-actions .btn-action {
    padding: 4px 8px;
}

/* Dashboard Chart Container (if using Chart.js or similar) */
.chart-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    text-align: center;
}

.chart-container canvas {
    max-width: 100%;
    height: auto;
}

/* Login/Register Page Specific */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e0f2f1; /* Light teal background */
}

.auth-card {
    background-color: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-card h2 {
    color: #00796b;
    margin-bottom: 25px;
    font-size: 2em;
}

.auth-card .input-group {
    margin-bottom: 20px;
}

.auth-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    margin-bottom: 15px;
}

.auth-card p {
    margin-top: 20px;
    font-size: 0.95em;
    color: #666;
}


/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* Responsive Design */
@media (max-width: 992px) {
    .sidebar {
        width: 200px; /* Slightly smaller sidebar */
    }
    .main-content {
        margin-left: 200px;
    }
    .header h1 {
        font-size: 1.5em;
    }
    .profile-info span {
        display: none; /* Hide name to save space */
    }
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 80px; /* Collapsed sidebar */
    }
    .sidebar-header h3 {
        font-size: 0; /* Hide text */
        overflow: hidden;
        width: 0;
        height: 0;
    }
    .sidebar ul li a {
        padding: 12px 0; /* No horizontal padding */
        justify-content: center; /* Center icons */
    }
    .sidebar ul li a i {
        margin-right: 0; /* Remove icon margin */
    }
    .sidebar ul li a span {
        display: none; /* Hide text labels */
    }
    .sidebar ul li a:hover,
    .sidebar ul li a.active {
        padding-left: 0; /* No indent on hover */
    }
    .sidebar ul li ul { /* Hide submenus completely */
        display: none;
    }

    .main-content {
        margin-left: 80px; /* Adjust margin for collapsed sidebar */
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .header h1 {
        font-size: 1.3em;
    }
    .profile-info {
        width: 100%;
        justify-content: flex-end; /* Push profile icon to right */
    }

    .invoice-summary {
        width: 100%;
        float: none;
    }

    .dashboard-grid, .notes-grid {
        grid-template-columns: 1fr; /* Stack columns on very small screens */
    }
    .data-table th, .data-table td {
        padding: 10px 8px; /* Reduce padding for smaller screens */
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px; /* Less padding on very small screens */
    }
    .card {
        padding: 15px; /* Less padding in cards */
    }
    .input-group input, .input-group textarea, .input-group select {
        font-size: 0.9em;
    }
    .btn-primary, .btn-secondary {
        padding: 8px 15px;
        font-size: 0.9em;
    }
}