@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --background: #fafbfc;
    --surface: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --radius: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Rubik', sans-serif;
    background: #f0f4f8;
    color: #2c3e50;
    margin: 0;
    padding-left: 24px;
    padding-right: 24px;
    padding-top: 70px; /* תעדכן לפי גובה ה-navbar שלך */
    padding-bottom: 24px; /* תעדכן לפי גובה ה-navbar שלך */
    direction: rtl;
    text-align: right;
}

body, svg, text {
    font-family: 'Rubik', sans-serif;
}

h1 {
    font-weight: 700;
    color: #1a5276;
    margin-bottom: 8px;
    font-size: 28px;
}

p.subtitle {
    font-size: 16px;
    color: #7f8c8d;
    margin-bottom: 24px;
}

.wrap {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 15px;
    align-items: stretch;
}

/* ברירת מחדל - לטלפון */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    border: 1px dashed #d1e2f0;
    height: auto;
    max-height: none; /* בטלפון נותנים חופש מלא */
}

/* במסכים גדולים - מחשב */
@media (min-width: 900px) {
    .card.drawing-card {
        max-height: 80vh; /* לא לחרוג מגובה חלון */
        overflow: hidden; /* שלא תהיה גלילה פנימית */
    }
}

.card.drawing-card {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden; /* חוסם חריגה */
}

    .card.drawing-card svg {
        width: 100%;
        height: 100%;
        max-height: 100%;
        object-fit: contain; /* שומר על פרופורציות בתוך הקונטיינר */
    }

.card h2 {
    margin-top: 10px;
    font-size: 20px;
    color: #34495e;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 12px;
    margin-bottom: 12px;
    font-weight: 600;
}

label {
    display: block;
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* שדות מספריים, טקסט ושדות בחירה */
input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 3px;
    border: 1px solid #dfe6e9;
    border-radius: 10px;
    box-sizing: border-box;
    background: #f8f9fb;
    font-size: 15px;
    color: #2c3e50;
    transition: all 0.3s ease;
}

    input[type="number"]:focus,
    input[type="text"]:focus,
    select:focus {
        outline: none;
        border-color: #3498db;
        background: #fff;
        box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
    }

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.readout-container {
    margin-top: 24px;
    background: #eef5fb;
    border-radius: 12px;
    padding: 18px;
    border: 1px dashed #d1e2f0;
}

    .readout-container h3 {
        margin: 0 0 10px;
        font-size: 16px;
        color: #34495e;
        font-weight: 600;
    }

.readout-item {
    font-size: 15px;
    color: #555;
    margin-bottom: 8px;
}

    .readout-item strong {
        color: #1a5276;
        font-weight: 700;
    }

svg {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    height: 100%;
    max-height: 72vh;
    display: block; /* שלא יגרום לגלילה מיותרת */
    margin: 0 auto; /* מרכז אופקית */
}

text {
    font-size: 13px;
    font-family: 'Courier New', monospace;
    fill: #2c3e50;
}

.dim {
    stroke: #2c3e50;
    stroke-width: 1;
    marker-start: url(#arr);
    marker-end: url(#arr);
}

.svg-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #bdc3c7;
    font-size: 24px;
    text-align: center;
    user-select: none;
}

.loading-spinner {
    display: none;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin: 0 8px;
}

#calcBtn.loading .loading-spinner {
    display: inline-block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

.note-box {
    fill: #fff59d; /* רקע צהוב כמו מרקר */
    stroke: #2c3e50; /* מסגרת כהה */
    stroke-dasharray: 4 2; /* מקווקו */
    rx: 5; /* פינות מעוגלות */
}

.note-text {
    font-size: 13px;
    font-family: 'Rubik', sans-serif;
    fill: #2c3e50;
    font-weight: 600;
    /* יישור אופקי */
    text-anchor: middle;
}

.card h2:nth-of-type(2) {
    margin-top: 16px;
}

/* File Upload */
.file-upload {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0rem;
    padding: 0.8rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

    .file-upload:hover {
        border-color: var(--primary);
        background: rgba(99, 102, 241, 0.05);
    }

    .file-upload input[type="file"] {
        display: none;
    }

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    margin-top: revert-layer;
}

    .file-label:hover {
        background: var(--primary-dark);
        transform: translateY(-1px);
    }

.file-name {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation */
nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    position: fixed; /* מקבע למעלה */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    position: relative;
}

    .nav-link:hover,
    .nav-link.active {
        color: var(--primary);
        background: rgba(99, 102, 241, 0.1);
    }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .nav-container {
        max-width: 1400px;
        margin: 0 auto;
        display: flex;
        padding: 0.6rem 2rem;
        flex-direction: row-reverse;
    }

    .nav-links {
        display: none; /* מוסתר בנייד עד פתיחה */
        flex-direction: column;
        gap: 1rem;
        position: absolute;
        top: 100%; /* מתחת ל-navbar */
        right: 0;
        background: var(--surface);
        border: 1px solid var(--border-light);
        border-radius: var(--radius);
        padding: 1rem;
        box-shadow: var(--shadow-lg);
    }

        .nav-links.active {
            display: flex; /* מופיע כשפותחים */
        }

    .nav-toggle {
        display: block;
        font-size: 0.8rem;
        margin-left: 71px;
        margin-top: 0px;
    }

    .file-name {
        flex: 1;
        font-size: 0.6rem;
        color: var(--text-secondary);
        white-space: nowrap;
    }
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

button {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: -15px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

    .btn-primary:hover {
        background: var(--primary-dark);
        transform: translateY(-1px);
        box-shadow: var(--shadow-lg);
    }

.btn-secondary {
    background: var(--secondary);
    color: white;
}

    .btn-secondary:hover {
        background: #059669;
        transform: translateY(-1px);
        box-shadow: var(--shadow-lg);
    }

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

    .loading::after {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
        animation: loading 1.5s infinite;
    }

@keyframes loading {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* עיצוב רגיל - פוקוס */
input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* שדה שגוי - גבול אדום */
input.error {
    border-color: #f44336 !important;
    background: linear-gradient(135deg, #ffebee 0%, #fce4ec 100%) !important;
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1) !important;
    animation: shake 0.5s ease-in-out;
}

/* שדה תקין - מילוי אדום יפה */
input.valid {
    border-color: #e91e63 !important;
    background: linear-gradient(135deg, #ffe0e8 0%, #fce4ec 50%, #f8bbd9 100%) !important;
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.15) !important;
    color: #880e4f;
    font-weight: 500;
}

/* אנימציה לרעידה */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}
