/**
 * Custom CSS for Pythagoras Square Application
 * Modern, clean design with Bootstrap 5
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Light theme */
    --bg-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-body: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --accent: #667eea;
    --accent-hover: #5a6fd6;
}

[data-bs-theme="dark"] {
    --bg-main: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-body: #0f0f1a;
    --card-bg: #1e1e30;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #667eea;
    --accent-hover: #7b8ff0;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Header
   ========================================================================== */
header.navbar {
    background: var(--primary-gradient) !important;
    padding: 1rem 0;
    border: none;
}

header .navbar-brand {
    color: #fff !important;
    font-weight: 600;
    font-size: 1.25rem;
}

header .navbar-brand i {
    opacity: 0.9;
}

#theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    transition: var(--transition);
}

#theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(15deg);
}

/* ==========================================================================
   Main Content
   ========================================================================== */
main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
}

/* Все секции внутри main занимают 100% ширины */
main.container > section {
    width: 100%;
}

/* Центрирование формы когда нет результатов */
main.container:not(.has-results) {
    justify-content: center;
}

main.container.has-results {
    justify-content: flex-start;
}

/* Results section full width */
.result__hidden {
    width: 100%;
}

.result__wrap.row {
    width: 100%;
    margin: 0;
    justify-content: center;
}

.result__cube {
    width: 100%;
}

/* ==========================================================================
   Calculator Card
   ========================================================================== */
.card.shadow-lg {
    background: var(--card-bg);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.card-title {
    color: var(--text-primary);
    font-weight: 600;
}

.card-title i {
    color: var(--accent);
}

/* Input styling */
.input-group {
    border-radius: 12px;
    overflow: hidden;
}

.input-group-text {
    background: var(--accent);
    border: none;
    color: #fff;
    padding: 0.75rem 1rem;
}

.matrix__input,
#date-input {
    border: 2px solid #e0e0e0;
    border-left: none;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    transition: var(--transition);
}

.matrix__input:focus,
#date-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    outline: none;
}

[data-bs-theme="dark"] .matrix__input,
[data-bs-theme="dark"] #date-input {
    background: #2a2a40;
    border-color: #3a3a50;
    color: var(--text-primary);
}

/* Calculate button */
.matrix__button {
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.matrix__button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5) !important;
    background: var(--primary-gradient) !important;
    color: #fff !important;
}

.matrix__button:active {
    transform: translateY(0);
}

/* ==========================================================================
   Results Section
   ========================================================================== */
.result__hidden {
    display: none;
}

.result.show .result__hidden {
    display: block;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results wrapper */
.result__wrap.row {
    background: transparent !important;
    margin: 0;
}

/* Birth data card */
.result__big {
    background: transparent;
    border: none;
    height: auto;
    padding: 0;
}

article.card.shadow {
    background: var(--card-bg);
    border: none;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.card-header.bg-primary {
    background: var(--primary-gradient) !important;
    border: none;
    padding: 1rem 1.25rem;
}

.card-header .card-title {
    color: #fff;
    font-size: 1rem;
}

.card-header .card-title i {
    color: #fff;
}

/* Birth data card body */
.result__big .row {
    justify-content: space-between;
    padding: 1rem 1.25rem;
    gap: 10px;
}

.result__big .row > div[class*="col-"] {
    width: auto;
    flex: 0 0 auto;
}

/* Badges */
.badge.bg-secondary {
    background: #e8e8f0 !important;
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.badge.bg-primary {
    background: var(--primary-gradient) !important;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

[data-bs-theme="dark"] .badge.bg-secondary {
    background: #3a3a50 !important;
    color: var(--text-primary);
}

/* ==========================================================================
   Matrix Grid
   ========================================================================== */
.result__cube {
    background: transparent;
}

.result__cube h3 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.result__cube h3 i {
    color: var(--accent);
}

/* Matrix cards */
.result__cube .card {
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    cursor: pointer;
}

.result__cube .card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-hover-shadow) !important;
}

.result__cube .card-body {
    padding: 1.25rem;
}

.result__cube .card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.result__cube .card-text {
    font-size: 1.5rem !important;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result__cube .text-info {
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   Additional Characteristics (Right Column)
   ========================================================================== */
.result__right h3 {
    color: var(--text-primary);
    font-weight: 600;
}

.result__right h3 i {
    color: var(--accent);
}

.result__right .card {
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    cursor: pointer;
}

.result__right .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-hover-shadow) !important;
}

.result__right .card-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 90px;
}

.result__right .card-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.result__right .card-text {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5rem;
}

/* Additional characteristics card colors */
.result__right .card:nth-of-type(1) {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border-left: 4px solid #f56565;
}

.result__right .card:nth-of-type(2) {
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    border-left: 4px solid #48bb78;
}

.result__right .card:nth-of-type(3) {
    background: linear-gradient(135deg, #fffff0 0%, #fefcbf 100%);
    border-left: 4px solid #ecc94b;
}

.result__right .card:nth-of-type(4) {
    background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 100%);
    border-left: 4px solid #a0aec0;
}

.result__right .card:nth-of-type(5) {
    background: linear-gradient(135deg, #faf5ff 0%, #e9d8fd 100%);
    border-left: 4px solid #9f7aea;
}

[data-bs-theme="dark"] .result__right .card:nth-of-type(1) {
    background: linear-gradient(135deg, #2d2030 0%, #3d2a3a 100%);
    border-left: 4px solid #f56565;
}

[data-bs-theme="dark"] .result__right .card:nth-of-type(2) {
    background: linear-gradient(135deg, #1a2e1a 0%, #2a3d2a 100%);
    border-left: 4px solid #48bb78;
}

[data-bs-theme="dark"] .result__right .card:nth-of-type(3) {
    background: linear-gradient(135deg, #2d2d1a 0%, #3d3d2a 100%);
    border-left: 4px solid #ecc94b;
}

[data-bs-theme="dark"] .result__right .card:nth-of-type(4) {
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3a 100%);
    border-left: 4px solid #a0aec0;
}

[data-bs-theme="dark"] .result__right .card:nth-of-type(5) {
    background: linear-gradient(135deg, #251e30 0%, #352a40 100%);
    border-left: 4px solid #9f7aea;
}

/* ==========================================================================
   Loader
   ========================================================================== */
.result__loader {
    display: none;
}

.result.loader .result__loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 3px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    background: var(--primary-gradient) !important;
    margin-top: auto;
}

footer .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* ==========================================================================
   Dark Theme Overrides
   ========================================================================== */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] article.card.shadow {
    background: var(--card-bg);
}

[data-bs-theme="dark"] .result__cube .card,
[data-bs-theme="dark"] .result__right .card {
    background: var(--card-bg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .result__cube .card:hover,
[data-bs-theme="dark"] .result__right .card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background: transparent !important;
}

/* ==========================================================================
   Form Validation
   ========================================================================== */
.form-control.is-valid {
    border-color: #11998e;
}

.form-control.is-invalid {
    border-color: #f5576c;
}

.valid-feedback {
    color: #11998e;
}

.invalid-feedback {
    color: #f5576c;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1199.98px) {
    .result__right {
        margin-top: 0;
    }
}

@media (max-width: 991.98px) {
    .result__wrap.row {
        flex-direction: column;
    }
    
    .result__left,
    .result__right {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
    
    .result__right {
        margin-top: 2rem;
    }
    
    /* На планшетах показываем характеристики в сетке */
    .result__right article {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 1rem;
    }
    
    .result__right article > h3 {
        grid-column: 1 / -1;
    }
    
    .result__right .card {
        margin-bottom: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .matrix__button {
        width: 100%;
        padding: 1rem;
    }
    
    .result__cube .card-body {
        padding: 1rem;
    }
    
    .result__cube .card-text {
        font-size: 1.25rem !important;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */
.result.show .result__cube .card {
    animation: fadeInUp 0.4s ease-out backwards;
}

.result.show .result__cube .row:nth-child(1) .col-4:nth-child(1) .card { animation-delay: 0.1s; }
.result.show .result__cube .row:nth-child(1) .col-4:nth-child(2) .card { animation-delay: 0.15s; }
.result.show .result__cube .row:nth-child(1) .col-4:nth-child(3) .card { animation-delay: 0.2s; }
.result.show .result__cube .row:nth-child(2) .col-4:nth-child(1) .card { animation-delay: 0.2s; }
.result.show .result__cube .row:nth-child(2) .col-4:nth-child(2) .card { animation-delay: 0.25s; }
.result.show .result__cube .row:nth-child(2) .col-4:nth-child(3) .card { animation-delay: 0.3s; }
.result.show .result__cube .row:nth-child(3) .col-4:nth-child(1) .card { animation-delay: 0.3s; }
.result.show .result__cube .row:nth-child(3) .col-4:nth-child(2) .card { animation-delay: 0.35s; }
.result.show .result__cube .row:nth-child(3) .col-4:nth-child(3) .card { animation-delay: 0.4s; }
.result.show .result__cube .row:nth-child(4) .col-4:nth-child(1) .card { animation-delay: 0.4s; }
.result.show .result__cube .row:nth-child(4) .col-4:nth-child(2) .card { animation-delay: 0.45s; }
.result.show .result__cube .row:nth-child(4) .col-4:nth-child(3) .card { animation-delay: 0.5s; }

.result.show .result__right .card {
    animation: fadeInUp 0.4s ease-out backwards;
}

.result.show .result__right .card:nth-of-type(1) { animation-delay: 0.15s; }
.result.show .result__right .card:nth-of-type(2) { animation-delay: 0.25s; }
.result.show .result__right .card:nth-of-type(3) { animation-delay: 0.35s; }
.result.show .result__right .card:nth-of-type(4) { animation-delay: 0.45s; }
.result.show .result__right .card:nth-of-type(5) { animation-delay: 0.55s; }
