
/* CSS Variables for Safe Areas */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    gap: 0;
    position: relative;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

/* Header */
.dashboard-header {
    width: 100%;
    padding: 15px 20px;
    background: #E5E5E5;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: calc(15px + var(--safe-area-top));
}

/* Header Content */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

/* Welcome Container */
.welcome-container {
    flex: 1;
    opacity: 1;
    transition: opacity 0.3s ease, height 0.3s ease;
}

.welcome-container.hidden {
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* Welcome Text */
.welcome-text {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin: 0;
    animation: fadeIn 0.5s ease-out;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search */
.search-container {
    position: relative;
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.search-container.expanded {
    width: 100%;
    max-width: 300px;
    padding: 8px 40px 8px 16px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.search-container.expanded .search-input {
    opacity: 1;
    width: 100%;
    pointer-events: auto;
}

.search-container.expanded .search-icon {
    left: 12px;
    width: 18px;
    height: 18px;
}

.search-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.search-input {
    width: 0;
    padding: 8px 40px 8px 36px;
    border: none;
    background: transparent;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.95rem;
    color: #1a1a1a;
    outline: none;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: #666;
    opacity: 0.6;
}

.close-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-search-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.close-search-btn:hover img {
    opacity: 1;
}

/* Settings and Logout Buttons */
.settings-btn, .logout-btn {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.settings-btn:hover, .logout-btn:hover {
    background: #f8f8f8;
    transform: scale(1.05);
}

.settings-btn:active, .logout-btn:active {
    transform: scale(0.95);
}

.settings-btn img, .logout-btn img {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

/* Main Content */
.dashboard-main {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    margin: 0 auto;
}

/* Estimate Card Link */
.estimate-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.3s ease;
}

.estimate-card-link:hover {
    transform: translateY(-2px);
}

/* Estimate Card */
.estimate-card {
    margin-top: 10px;
    background: #F8F8F8;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    animation: fadeInUp 0.8s ease-out 0.8s both;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.estimate-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    background: #ffffff;
}

.card-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-label {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #282828;
    opacity: 0.7;
    line-height: 1.2;
}

.card-value {
    font-family: 'Unbounded', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #282828;
    line-height: 1.2;
}

.card-value.price {
    color: #2c5aa0;
    font-size: 1.1rem;
}

/* Card Footer */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
}

.status-info, .date-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.date-value {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: #282828;
    opacity: 0.8;
}

/* Status Badges */
.status-badge {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    text-align: center;
}

.status-badge.in-progress {
    background-color: rgba(94, 123, 0, 0.1);
    color: rgba(94, 123, 0, 1);
}

.status-badge.completed {
    background-color: rgba(40, 167, 69, 0.1);
    color: rgba(40, 167, 69, 1);
}

.status-badge.pending {
    background-color: rgba(255, 193, 7, 0.1);
    color: rgba(255, 193, 7, 1);
}

/* Card Actions */
.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
    position: absolute;
    top: 15px;
    right: 15px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn img {
    width: 16px;
    height: 16px;
}

.delete-btn:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

/* Add Smeta Button */
.add-smeta-btn {
    position: fixed;
    bottom: calc(30px + var(--safe-area-bottom));
    right: 20px;
    width: 60px;
    height: 60px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    text-decoration: none;
}

.add-smeta-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
    background: #f8f8f8;
}

.add-smeta-btn:active {
    transform: scale(0.95);
}

.add-smeta-btn img {
    width: 24px;
    height: 24px;
    opacity: 0.8;
}

/* Responsive Design with Safe Areas */
@media (max-width: 480px) {
    .dashboard-header {
        padding: 12px 15px;
        padding-top: calc(12px + var(--safe-area-top));
    }
    
    .header-content {
        gap: 8px;
    }
    
    .dashboard-main {
        padding: 0 15px 15px;
        gap: 12px;
    }
    
    .estimate-card {
        padding: 15px;
        gap: 12px;
    }
    
    .card-value {
        font-size: 0.95rem;
    }
    
    .card-value.price {
        font-size: 1rem;
    }
    
    .settings-btn, .logout-btn {
        width: 36px;
        height: 36px;
    }
    
    .add-smeta-btn {
        bottom: calc(25px + var(--safe-area-bottom));
        right: 15px;
        width: 55px;
        height: 55px;
    }
    
    .card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .welcome-text {
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .dashboard-header {
        padding: 10px 12px;
        padding-top: calc(10px + var(--safe-area-top));
    }
    
    .dashboard-main {
        padding: 0 12px 12px;
    }
    
    .estimate-card {
        padding: 12px;
        gap: 10px;
    }
    
    .card-actions {
        top: 10px;
        right: 10px;
    }
    
    .add-smeta-btn {
        bottom: calc(20px + var(--safe-area-bottom));
        right: 12px;
        width: 50px;
        height: 50px;
    }
    
    .add-smeta-btn img {
        width: 20px;
        height: 20px;
    }
    
    .welcome-text {
        font-size: 0.9rem;
    }
}

/* iPhone Notch Support */
@supports (padding: max(0px)) {
    .dashboard-container {
        padding-top: max(0px, var(--safe-area-top));
        padding-bottom: max(0px, var(--safe-area-bottom));
    }
    
    .dashboard-header {
        padding-top: max(15px, calc(15px + var(--safe-area-top)));
    }
    
    .add-smeta-btn {
        bottom: max(30px, calc(30px + var(--safe-area-bottom)));
    }
}

/* Animation for new cards */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scrollbar styling for dashboard main */
.dashboard-main::-webkit-scrollbar {
    width: 4px;
}

.dashboard-main::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-main::-webkit-scrollbar-thumb {
    background: #CECECE;
    border-radius: 2px;
}

.dashboard-main::-webkit-scrollbar-thumb:hover {
    background: #b8b8b8;
}

/* Hide scrollbar when not needed */
.dashboard-main {
    scrollbar-width: thin;
    scrollbar-color: #CECECE transparent;
}

/* Стили для состояний */
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.skeleton-card {
    background: #f8f8f8;
    border-radius: 15px;
    padding: 20px;
    height: 150px;
    margin-bottom: 15px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { background-color: #f8f8f8; }
    50% { background-color: #e0e0e0; }
    100% { background-color: #f8f8f8; }
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #666;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: #f8f9fa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon img {
    width: 40px;
    height: 40px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #333;
}

.empty-state p {
    color: #666;
    line-height: 1.5;
}

.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #e74c3c;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.retry-btn, .report-btn {
    background: #5E7B00;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 0.5rem;
    font-family: 'Unbounded', sans-serif;
}

.report-btn {
    background: #e74c3c;
}

.retry-btn:hover {
    background: #4a6100;
}

.report-btn:hover {
    background: #c0392b;
}

/* Заголовок панели */
.dashboard-header-section {
    margin-bottom: 1.5rem;
}

.dashboard-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.smeta-count {
    font-size: 0.9rem;
    color: #666;
}

/* Демо-секция */
.demo-section-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    color: #666;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.demo-card {
    opacity: 0.8;
    position: relative;
}

.demo-card::before {
    content: "ДЕМО";
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff6b6b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Стили для поиска */
.search-results-info {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 1rem;
}

/* Подсветка найденных элементов */
.estimate-card-link.search-match {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(94, 123, 0, 0.15);
}

.company-name {
    font-weight: 600;
    color: #1a1a1a;
}

/* Фильтр */
.filter-container {
    margin: 10px 0;
}

#statusFilter {
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    background: #ffffff;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.9rem;
    color: #1a1a1a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="%23666" d="M7 10l5 5 5-5H7z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

#statusFilter:focus {
    outline: none;
    box-shadow: 0 2px 8px rgba(94, 123, 0, 0.2);
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Unbounded', sans-serif;
}

.cancel-btn {
   
    background: #ccc;
}

.confirm-btn {
    background: #e74c3c;
    color: white;
}

.cancel-btn:hover {
    background: #bbb;
}

.confirm-btn:hover {
    background: #c0392b;
}

/* Адаптивность */
@media (max-width: 768px) {
    .dashboard-title {
        font-size: 1.3rem;
    }
    
    .empty-state {
        padding: 3rem 1rem;
    }
    
    .empty-state-icon {
        width: 60px;
        height: 60px;
    }
    
    .empty-state-icon img {
        width: 30px;
        height: 30px;
    }
    
    .welcome-text {
        font-size: 1rem;
    }
    
    .search-container.expanded {
        max-width: 250px;
    }
}
