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

body {
    font-family: 'Inter', sans-serif;
    background-image: url('pilvikuva.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.4);
    z-index: -1;
    backdrop-filter: blur(2px);
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: 70px 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    min-height: 100vh;
}

/* Top Navigation */
.top-nav {
    grid-area: header;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    height: 50px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    width: 24px;
    height: 3px;
    background: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.user-email-btn:hover {
    background: #f3f0ff;
}

.user-email {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.user-email-btn svg {
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.user-email-btn:hover svg {
    color: #774be5;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.dropdown-item:hover {
    background: #f3f0ff;
    color: #774be5;
}

.dropdown-item svg {
    flex-shrink: 0;
    color: currentColor;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: #fafbfc;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-nav {
    padding: 20px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: #666;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item:hover {
    background: #f3f0ff;
    color: #774be5;
    box-shadow: inset 0 0 0 1px rgba(119, 75, 229, 0.08);
}

.nav-item.active {
    background: #f3f0ff;
    color: #774be5;
    border-left-color: #774be5;
    box-shadow: inset 0 0 0 1px rgba(119, 75, 229, 0.1);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.create-invoice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #774be5 0%, #8b5cf6 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(119, 75, 229, 0.2);
}

.create-invoice-btn:hover {
    background: linear-gradient(135deg, #6a42d1 0%, #7c4ee3 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(119, 75, 229, 0.3);
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: 30px;
    overflow-y: auto;
}

.content-header {
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 28px;
    color: #0e1c29;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.search-box svg {
    color: #9ca3af;
    flex-shrink: 0;
}

.search-box input {
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    width: 100%;
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    outline: none;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0e1c29;
}

.stat-value.success {
    color: #10b981;
}

.stat-value.pending {
    color: #f59e0b;
}

.stat-value.danger {
    color: #ef4444;
}

/* Revenue Chart Section */
.revenue-section {
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 24px;
    margin-bottom: 30px;
    border: 1px solid rgba(119, 75, 229, 0.08);
}

.revenue-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 20px;
}

.revenue-title-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.revenue-title {
    font-size: 18px;
    font-weight: 600;
    color: #0e1c29;
    margin: 0;
}

.revenue-total {
    font-size: 32px;
    font-weight: 700;
    color: #774be5;
    margin: 0;
}

.period-select {
    padding: 8px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.period-select:hover {
    border-color: #774be5;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Invoices Container */
.invoices-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Table View */
.table-view {
    overflow-x: auto;
}

.invoices-table {
    width: 100%;
    border-collapse: collapse;
}

.invoices-table thead {
    background: #f8f9fa;
}

.invoices-table th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoices-table td {
    padding: 18px 20px;
    border-top: 1px solid #f1f3f5;
    font-size: 14px;
}

.invoices-table tbody tr {
    transition: all 0.2s ease;
}

.invoices-table tbody tr:hover {
    background: linear-gradient(135deg, #faf5ff 0%, #f8f9fa 100%);
    box-shadow: inset 0 0 0 1px rgba(119, 75, 229, 0.08);
}

.invoice-number {
    font-weight: 600;
    color: #0e1c29;
}

.invoice-client {
    color: #333;
}

.invoice-amount {
    font-weight: 600;
    color: #0e1c29;
}

.invoice-date {
    color: #666;
    font-size: 13px;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.status-badge.paid {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.overdue {
    background: #fee2e2;
    color: #991b1b;
}

.action-btn {
    padding: 8px 16px;
    background: #774be5;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: #683dd7;
    transform: translateY(-1px);
}

.action-btn-danger {
    background: #ef4444;
}

.action-btn-danger:hover {
    background: #dc2626;
}

/* Status Dropdown */
.status-dropdown {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-dropdown:hover {
    border-color: #774be5;
    box-shadow: 0 0 0 3px rgba(119, 75, 229, 0.1);
}

.status-dropdown:focus {
    outline: none;
    border-color: #774be5;
    box-shadow: 0 0 0 3px rgba(119, 75, 229, 0.1);
}

.status-dropdown.pending {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.status-dropdown.paid {
    background: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

.status-dropdown.overdue {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Card View (Mobile) */
.card-view {
    display: none;
    padding: 20px;
    gap: 16px;
    flex-direction: column;
}

.invoice-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invoice-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.invoice-card-number {
    font-weight: 700;
    font-size: 16px;
    color: #0e1c29;
}

.invoice-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #f1f3f5;
}

.invoice-card-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.invoice-card-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.invoice-card-actions {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #f1f3f5;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-wrapper {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .sidebar {
        position: fixed;
        left: -250px;
        top: 70px;
        height: calc(100vh - 70px);
        z-index: 200;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .main-content {
        padding: 20px;
    }

    .content-header h1 {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 0 20px;
    }

    .logo {
        height: 40px;
    }

    .main-content {
        padding: 16px;
    }

    .content-header h1 {
        font-size: 22px;
        margin-bottom: 16px;
    }

    .header-actions {
        flex-direction: column;
        gap: 12px;
    }

    .search-box {
        max-width: 100%;
        min-width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 16px;
    }

    .revenue-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .revenue-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .revenue-total {
        font-size: 28px;
    }

    .period-select {
        width: 100%;
    }

    .chart-container {
        height: 250px;
    }

    .stat-label {
        font-size: 12px;
    }

    .stat-value {
        font-size: 24px;
    }

    .table-view {
        display: none;
    }

    .card-view {
        display: flex;
    }

    .invoices-container {
        background: transparent;
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .user-email {
        display: none;
    }
}
